Page MenuHome

OSL console message missing
Closed, ArchivedPublic

Description

System Information
Arch Linux

Blender Version
Blender Version 2.70a
Build hash: f93bc76

Short description of error
Functions printf(), error(), warning() does not give any output in system console and blender internal info.
Even after system update, and blender reinstallation.

Exact steps for others to reproduce the error
Declaration of some variable:

int Test = 5;

then print:

printf("%d", Test);

Details

Type
Bug

Event Timeline

Dominik (grrrl212) updated the task description. (Show Details)
Dominik (grrrl212) raised the priority of this task from to Needs Triage.
Dominik (grrrl212) added a project: BF Blender.
Dominik (grrrl212) set Type to Bug.
Thomas Dinges (dingto) raised the priority of this task from Normal to Confirmed.May 27 2014, 7:44 AM

I can confirm this. Tested with this simple .osl shader.

Tested on Windows x64, vc2008.

The problem is that the print statement is getting optimized out. The workaround is to run Blender with the environment variable OSL_OPTIONS="optimize=0".

I'm not sure how to best deal with this, we can either advise user to use this environment variable, or add some option in Blender to enable OSL shader debugging which then sets this and perhaps other options useful for debugging.

Sergey Sharybin (sergey) closed this task as Archived.Jun 4 2014, 8:29 PM

I don't think it's a bug, just likely shader gets optimized out to a constant. If you set OSL_OPTIONS environment variable to "optimize=0" then you'll totally see the prints.

In fact, the same exact issue has been discussed already there https://github.com/imageworks/OpenShadingLanguage/issues/267

@Brecht Van Lommel (brecht), correct me if i'm wrong, but it's just specific of how OSL optimizes the shaders. It's done for speed, if you want to debug using printfs, you need to disable optimizations.

I've just tested this in latest blender versions 2.79 and 2.80 on macOS and can confirm the prints don't work, with OSL_OPTIONS environment variable set to "optimize=0".

@Prasanth G (gp), Works with the demo shader on Linux. Could be something platform specific or specific to your setup.

Please make a new report, giving all the details, including simple .blend file which demonstrates the issue.