[osg-users] Crash when application closes if linking with OSG

Robert Osfield robert.osfield at gmail.com
Mon Oct 5 03:18:38 PDT 2015


Hi David,

I have just had a look at DisplaySettings.cpp and there is a line:

   OSG_INIT_SINGLETON_PROXY(ProxyInitDisplaySettings,
DisplaySettings::instance())

That should in theory force the initialization of the
DisplaySettings::instance() singleton during the static initialization of
the osg library.  In your case it sounds like the Registry::instance() is
being constructed before this which I'm surprised by.

Perhaps it's simply the InitRegistry construction/destruction in
src/osgViewer/ViewerBase.cpp is the root of the problem.  Perhaps just
removing this would be sufficient.

Robert.


On 5 October 2015 at 10:24, David Siñuela <david.sinuela at pix4d.com> wrote:

> Hello,
>
> Thanks for your input. We can wait for an upstream fix, in the meanwhile
> we will patch it in our development branch.
>
> I tried your proposed solution, calling DisplaySettings::instance() from
> main(), and it didn't work, when s_InitRegistry is destroyed the
> DisplaySettings::s_displaySettings has been destroyed already. It can be
> fixed by defining a static initializer like InitRegistry that simply calls
> DisplaySettings::instance() in our program. If I understood it correctly
> this works because the compiler/linker will see this static member and
> DisplaySettings::s_displaySettings before InitRegistry, changing the order
> of initialization so that DisplaySettings::s_displaySettings is allocated
> before s_InitRegistry and deallocated after.
>
> It can also be fixed by calling "osgDB::DatabasePager::prototype()" or
> "osg::DisplaySettings::instance()" from InitRegistry's constructor.
>
> Regards,
> David
>
>
>
> On Fri, Oct 2, 2015 at 6:28 PM, Robert Osfield <robert.osfield at gmail.com>
> wrote:
>
>> Hi David,
>>
>> Curious bug.  Perhaps another solution would be to call
>> DisplaySettings::instance() at the start of main.
>>
>> An actual bug fix might be to put in a proxy object into
>> src/osg/DisplauySettings.cpp that forces that DisplaySettings::instance()
>> to be constructed during static initialization, this would obviously
>> require a patch to the core OSG, something I'm happy to do, but won't help
>> you right away.
>>
>> Robert.
>>
>>
>>
>> On 2 October 2015 at 17:07, David Siñuela <david.sinuela at pix4d.com>
>> wrote:
>>
>>> Hello,
>>>
>>> We have a Qt application that uses OSG for the 3D viewer/editor, but the
>>> OSG viewer may not be used if the user does not open the 3D view tab. We
>>> are in the process of upgrading to OSG 3.4 and we noticed that the
>>> application crashes when the user quits if the 3D view is never open.
>>>
>>> The problem seems to be the order in which the static variables are
>>> destroyed at shutdown. The stacktrace looks like this:
>>>
>>> Program received signal SIGSEGV, Segmentation fault.
>>> 0x0000000001d8a0b0 in
>>> osg::DisplaySettings::getNumOfHttpDatabaseThreadsHint (this=0x0) at
>>> /home/siu/src/pix4dmapper/2.1/external_tmp/build/openscenegraph/include/osg/DisplaySettings:203
>>> (gdb) bt
>>> #0  0x0000000001d8a0b0 in
>>> osg::DisplaySettings::getNumOfHttpDatabaseThreadsHint (this=0x0) at
>>> /home/siu/src/pix4dmapper/2.1/external_tmp/build/openscenegraph/include/osg/DisplaySettings:203
>>> #1  0x0000000001d86b47 in osgDB::DatabasePager::DatabasePager
>>> (this=0x3a10fb0) at
>>> /home/siu/src/pix4dmapper/2.1/external_tmp/build/openscenegraph/src/osgDB/DatabasePager.cpp:1111
>>> #2  0x0000000001d87815 in osgDB::DatabasePager::prototype () at
>>> /home/siu/src/pix4dmapper/2.1/external_tmp/build/openscenegraph/src/osgDB/DatabasePager.cpp:1235
>>> #3  0x0000000001d1ceef in InitRegistry::~InitRegistry (this=0x32cc6f3
>>> <s_InitRegistry>, __in_chrg=<optimized out>) at
>>> /home/siu/src/pix4dmapper/2.1/external_tmp/build/openscenegraph/src/osgViewer/ViewerBase.cpp:53
>>> #4  0x00007fffec82df88 in __run_exit_handlers () from /usr/lib/libc.so.6
>>> #5  0x00007fffec82dfd5 in exit () from /usr/lib/libc.so.6
>>> #6  0x00007fffec818617 in __libc_start_main () from /usr/lib/libc.so.6
>>> #7  0x0000000000ea3709 in _start ()
>>>
>>> As shown in the trace calling DatabasePager::prototype() is creating the
>>> static DatabasePager for the first time and this one calls
>>> osg::DisplaySettings::instance() which was released already. It is easily
>>> reproducible on linux with gcc. Removing the
>>> osgDB::DatabasePager::prototype() = 0; line fixes the crash but I am not
>>> sure about the intent of that line.
>>>
>>> Regards,
>>>
>>> --
>>> David Sinuela Pastor
>>>
>>>
>>> *Pix4D SA*
>>> *EPFL Innovation Park*
>>> *Building D*
>>> *1015 Lausanne - Switzerland*
>>> *Email: <david.sinuela at pix4d.com>david.sinuela at pix4d.com
>>> <david.sinuela at gmail.com>*
>>> *Skype: david.sinuela.pix4d*
>>> *www.pix4d.com* <http://www.pix4d.com>
>>>
>>> _______________________________________________
>>> osg-users mailing list
>>> osg-users at lists.openscenegraph.org
>>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>>
>>>
>>
>> _______________________________________________
>> osg-users mailing list
>> osg-users at lists.openscenegraph.org
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>>
>
>
> --
> David Sinuela Pastor
>
>
> *Pix4D SA*
> *EPFL Innovation Park*
> *Building D*
> *1015 Lausanne - Switzerland*
> *Email: <david.sinuela at pix4d.com>david.sinuela at pix4d.com
> <david.sinuela at gmail.com>*
> *Skype: david.sinuela.pix4d*
> *www.pix4d.com* <http://www.pix4d.com>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20151005/ee25b3a2/attachment-0003.htm>


More information about the osg-users mailing list