segfault in case ogre init fails

Programmers discuss here anything related to FreeOrion programming. Primarily for the developers to discuss.

Moderator: Committer

Post Reply
Message
Author
User avatar
vincele
Space Dragon
Posts: 341
Joined: Sun Mar 23, 2014 6:10 pm

segfault in case ogre init fails

#1 Post by vincele »

I got the following segfault :

Code: Select all

main() caught exception(std::runtime_error): Failed to find an Ogre GL render system.

Program received signal SIGSEGV, Segmentation fault.
Ogre::Root::uninstallPlugin (this=0x7fffe40fc8d8, plugin=0x0)
    at /build/ogre-1.8-f16G5H/ogre-1.8-1.8.0+dfsg1/OgreMain/src/OgreRoot.cpp:1304
(gdb) bt
#0  Ogre::Root::uninstallPlugin (this=0x7fffe40fc8d8, plugin=0x0)
    at /build/ogre-1.8-f16G5H/ogre-1.8-1.8.0+dfsg1/OgreMain/src/OgreRoot.cpp:1304
#1  0x0000000000df1638 in mainSetupAndRunOgre ()
    at /home/vince/repo/upstream/FreeOrion-llvm/client/human/chmain.cpp:373
#2  0x0000000000dec0c3 in main (argc=1, argv=0x7fffffffe358)
    at /home/vince/repo/upstream/FreeOrion-llvm/client/human/chmain.cpp:88
And the following patch fixes it. The code throws a runtime exception before ois_input_plugin is initialized, so we should not unregister & delete in that case...

[The extension diff has been deactivated and can no longer be displayed.]

All the patches I'll provide for freeorion will be released under the GPL v2 or later license.
Let's unleash the dyson forest powa!

User avatar
adrian_broher
Programmer
Posts: 1156
Joined: Fri Mar 01, 2013 9:52 am
Location: Germany

Re: segfault in case ogre init fails

#2 Post by adrian_broher »

Shouldn't this patch be part of the sdl patch? How can I reproduce this error?
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz

Mitten.O
Programmer
Posts: 255
Joined: Sun Apr 06, 2014 4:15 pm

Re: segfault in case ogre init fails

#3 Post by Mitten.O »

Shouldn't this patch be part of the sdl patch?
No. The SDL patch replaces Ogre GUI. This seems to fix a corner case in Ogre GUI initialization.

If the SDL path does get adopted, this bug becomes obsolete,
there is no other connection.
Any code by me in this post is released under GPL 2.0 or later.

User avatar
vincele
Space Dragon
Posts: 341
Joined: Sun Mar 23, 2014 6:10 pm

Re: segfault in case ogre init fails

#4 Post by vincele »

adrian_broher wrote:Shouldn't this patch be part of the sdl patch? How can I reproduce this error?
No, this is current SVN code accessing uninitialized memory. I dunno how to reproduce, I was toying with an LLVM 3.6 ASAN build, and it segfaulted right at the first (an successive) run(s)...

If you follow the code in chmain.cpp int mainSetupAndRunOgre(), you'll see line 270 that in case getRenderSystemByName() is not successful, the exception throwing made the code go directly to cleanup code, which is not properly guarded against NULL pointers.

Edit: In fact, it happened because the file ogre_plugins.cfg was not present in the same directory as the freorion binary (I'm building out of source tree). So you can easily reproduce by renaming temporarily this file...
All the patches I'll provide for freeorion will be released under the GPL v2 or later license.
Let's unleash the dyson forest powa!

User avatar
adrian_broher
Programmer
Posts: 1156
Joined: Fri Mar 01, 2013 9:52 am
Location: Germany

Re: segfault in case ogre init fails

#5 Post by adrian_broher »

Thanks for the patch. Commited as r7572.
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz

Post Reply