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

2015-10-05 Thread David Siñuela
Hello Robert,

It is working fine now, I tested it on Linux and Windows.

Thanks!
David

On Mon, Oct 5, 2015 at 12:48 PM, Robert Osfield 
wrote:

> Hi David,
>
> I have removed the InitRegistry proxy object from
> src/osgViewer/ViewerBase.cpp and introduced OSG_INIT_SINGLETON_PROXY usage
> in DatabasePager.cpp and Registry.cpp which should ensure that the
> singleton's are initialized in a single threaded way and destructed in an
> appropriate order.  I have checked this change into svn/trunk and the
> OSG-3.4 branch. Changes are:
>
> Index: src/osgDB/DatabasePager.cpp
> ===
> --- src/osgDB/DatabasePager.cpp (revision 15130)
> +++ src/osgDB/DatabasePager.cpp (working copy)
> @@ -1236,6 +1236,8 @@
>  return s_DatabasePager;
>  }
>
> +OSG_INIT_SINGLETON_PROXY(ProxyInitDatabasePager,
> DatabasePager::prototype())
> +
>  DatabasePager* DatabasePager::create()
>  {
>  return DatabasePager::prototype().valid() ?
> Index: src/osgDB/Registry.cpp
> ===
> --- src/osgDB/Registry.cpp  (revision 15130)
> +++ src/osgDB/Registry.cpp  (working copy)
> @@ -214,7 +214,9 @@
>  return s_registry.get(); // will return NULL on erase
>  }
>
> +OSG_INIT_SINGLETON_PROXY(ProxyInitRegistry, Registry::instance())
>
> +
>  // definition of the Registry
>  Registry::Registry()
>  {
> Index: src/osgViewer/ViewerBase.cpp
> ===
> --- src/osgViewer/ViewerBase.cpp(revision 15142)
> +++ src/osgViewer/ViewerBase.cpp(working copy)
> @@ -40,23 +40,6 @@
>
>  using namespace osgViewer;
>
> -
> -struct InitRegistry
> -{
> -InitRegistry()
> -{
> -osgDB::Registry::instance();
> -}
> -
> -~InitRegistry()
> -{
> -osgDB::DatabasePager::prototype() = 0;
> -osgDB::Registry::instance(true);
> -}
> -};
> -
> -static InitRegistry s_InitRegistry;
> -
>  ViewerBase::ViewerBase():
>  osg::Object(true)
>  {
>
> This patch is also attached, under unix you can apply this with:
>
>   cd OpenSceneGraph
>   patch -p0 < singletons.patch
>
> Could you test this out and let me know if it works fine or not.
>
> Cheers,
> Robert.
>
>
>
> ___
> osg-users mailing list
> osg-users@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.sinu...@pix4d.com
*
*Skype: david.sinuela.pix4d*
*www.pix4d.com* 
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


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

2015-10-05 Thread David Siñuela
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 
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  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.
>> 0x01d8a0b0 in
>> osg::DisplaySettings::getNumOfHttpDatabaseThreadsHint (this=0x0) at
>> /home/siu/src/pix4dmapper/2.1/external_tmp/build/openscenegraph/include/osg/DisplaySettings:203
>> (gdb) bt
>> #0  0x01d8a0b0 in
>> osg::DisplaySettings::getNumOfHttpDatabaseThreadsHint (this=0x0) at
>> /home/siu/src/pix4dmapper/2.1/external_tmp/build/openscenegraph/include/osg/DisplaySettings:203
>> #1  0x01d86b47 in osgDB::DatabasePager::DatabasePager
>> (this=0x3a10fb0) at
>> /home/siu/src/pix4dmapper/2.1/external_tmp/build/openscenegraph/src/osgDB/DatabasePager.cpp:
>> #2  0x01d87815 in osgDB::DatabasePager::prototype () at
>> /home/siu/src/pix4dmapper/2.1/external_tmp/build/openscenegraph/src/osgDB/DatabasePager.cpp:1235
>> #3  0x01d1ceef in InitRegistry::~InitRegistry (this=0x32cc6f3
>> , __in_chrg=) at
>> /home/siu/src/pix4dmapper/2.1/external_tmp/build/openscenegraph/src/osgViewer/ViewerBase.cpp:53
>> #4  0x7fffec82df88 in __run_exit_handlers () from /usr/lib/libc.so.6
>> #5  0x7fffec82dfd5 in exit () from /usr/lib/libc.so.6
>> #6  0x7fffec818617 in __libc_start_main () from /usr/lib/libc.so.6
>> #7  0x00ea3709 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.sinu...@pix4d.com
>> *
>> *Skype: david.sinuela.pix4d*
>> *www.pix4d.com* <http://www.pix4d.com>
>>
>> ___
>> osg-users mailing list
>> osg-users@lists.openscenegraph.org
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>>
>
> ___
> osg-users mailing list
> osg-users@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.sinu...@pix4d.com
*
*Skype: david.sinuela.pix4d*
*www.pix4d.com* <http://www.pix4d.com>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


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

2015-10-02 Thread David Siñuela
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.
0x01d8a0b0 in osg::DisplaySettings::getNumOfHttpDatabaseThreadsHint
(this=0x0) at
/home/siu/src/pix4dmapper/2.1/external_tmp/build/openscenegraph/include/osg/DisplaySettings:203
(gdb) bt
#0  0x01d8a0b0 in
osg::DisplaySettings::getNumOfHttpDatabaseThreadsHint (this=0x0) at
/home/siu/src/pix4dmapper/2.1/external_tmp/build/openscenegraph/include/osg/DisplaySettings:203
#1  0x01d86b47 in osgDB::DatabasePager::DatabasePager
(this=0x3a10fb0) at
/home/siu/src/pix4dmapper/2.1/external_tmp/build/openscenegraph/src/osgDB/DatabasePager.cpp:
#2  0x01d87815 in osgDB::DatabasePager::prototype () at
/home/siu/src/pix4dmapper/2.1/external_tmp/build/openscenegraph/src/osgDB/DatabasePager.cpp:1235
#3  0x01d1ceef in InitRegistry::~InitRegistry (this=0x32cc6f3
, __in_chrg=) at
/home/siu/src/pix4dmapper/2.1/external_tmp/build/openscenegraph/src/osgViewer/ViewerBase.cpp:53
#4  0x7fffec82df88 in __run_exit_handlers () from /usr/lib/libc.so.6
#5  0x7fffec82dfd5 in exit () from /usr/lib/libc.so.6
#6  0x7fffec818617 in __libc_start_main () from /usr/lib/libc.so.6
#7  0x00ea3709 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.sinu...@pix4d.com
*
*Skype: david.sinuela.pix4d*
*www.pix4d.com* 
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org