zhangzdb / osgocean

Automatically exported from code.google.com/p/osgocean
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Null-pointer dereference #42

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
In our multi-threaded application, we have a thread that renders osg, and 
another one that displays a GUI. That GUI changes ocean properties, such as 
refraction.

When enabling/disabling refraction, a null-pointer is dereferenced in 
OceanScene::ViewData::cull()

I do not know the exact sequence that causes this, but I simply added a check 
for null-pointers and the problem went away.

Here's a patch file of my modifications in OceanScene.cpp.

Any idea why this might happen?

Original issue reported on code.google.com by francis....@cm-labs.com on 13 Feb 2012 at 8:51

Attachments:

GoogleCodeExporter commented 9 years ago
Hi Francis,

Thanks for pointing this out. I'm quite surprised this happens when you 
enable/disable refractions - all those functions do is set a flag for 
OceanScene to apply the setting on the next update traversal. I'll have a look 
at the code and see if anything jumps out at me. Although I have to confess 
I've not tested osgOcean in a multi-threaded application.

In the mean time I've applied your patch.

Cheers,

Kim.

Original comment by kcb...@googlemail.com on 14 Feb 2012 at 2:09

GoogleCodeExporter commented 9 years ago
I've tried to figure out what was going on, but could not find out the exact 
sequence. The lead I was following before I gave up and wrote this patch is as 
follows:

OceanScene::ViewData::init() will create the "osgOcean_EnableRefractions" 
variable with the current value from the OceanScene. Then it will look again at 
the value from the scene and create cameras. The value might have changed in 
the meanwhile.

Hope this helps.

Thank you very much Kim, for the fast response time. It's really appreciated.

Regards,
Francis

Original comment by francis....@cm-labs.com on 14 Feb 2012 at 3:31