New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault on exit (Linux) #11

Closed
Hiradur opened this Issue Jan 8, 2015 · 10 comments

Comments

Projects
None yet
5 participants
@Hiradur
Contributor

Hiradur commented Jan 8, 2015

Not much of an issue but may leave a bad impression ;)
When hitting the Quit button in the main menu:

Core was generated by `./RoR'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007fe91448913f in ?? () from /usr/lib/x86_64-linux-gnu/libxcb.so.1
(gdb) bt
#0  0x00007fe91448913f in ?? () from /usr/lib/x86_64-linux-gnu/libxcb.so.1
#1  0x00007fe918682bb8 in ?? () from /usr/lib/x86_64-linux-gnu/libX11.so.6
#2  0x00007fe918682cfc in ?? () from /usr/lib/x86_64-linux-gnu/libX11.so.6
#3  0x00007fe918682fcd in _XEventsQueued ()
   from /usr/lib/x86_64-linux-gnu/libX11.so.6
#4  0x00007fe91867512d in XPending ()
   from /usr/lib/x86_64-linux-gnu/libX11.so.6
#5  0x00007fe91b1685fc in OIS::LinuxMouse::_processXEvents() ()
   from /usr/lib/x86_64-linux-gnu/libOIS-1.3.0.so
#6  0x00007fe91b168982 in OIS::LinuxMouse::capture() ()
   from /usr/lib/x86_64-linux-gnu/libOIS-1.3.0.so
#7  0x0000000000749eb6 in InputEngine::Capture (this=0x340d780)
    at /home/-/Desktop/copy of rigsofrods-next-stable/source/main/utils/InputEngine.cpp:2134
#8  0x0000000000781ef1 in RoR::MainThread::MainMenuLoopUpdate (
    this=this@entry=0x7fffa1326ef0, seconds_since_last_frame=0,0500000007)
    at /home/-/Desktop/copy of rigsofrods-next-stable/source/main/main_sim/MainThread.cpp:1031
#9  0x0000000000782186 in RoR::MainThread::EnterMainMenuLoop (
    this=this@entry=0x7fffa1326ef0)
    at /home/-/Desktop/copy of rigsofrods-next-stable/source/main/main_sim/MainThread.cpp:861
#10 0x0000000000786bfd in RoR::MainThread::Go (this=this@entry=0x7fffa1326ef0)

When hitting exit from the drop down menu ingame:

Program received signal SIGSEGV, Segmentation fault.
0x00007fffefb6913f in ?? () from /usr/lib/x86_64-linux-gnu/libxcb.so.1
(gdb) bt
#0  0x00007fffefb6913f in ?? () from /usr/lib/x86_64-linux-gnu/libxcb.so.1
#1  0x00007ffff3d62bb8 in ?? () from /usr/lib/x86_64-linux-gnu/libX11.so.6
#2  0x00007ffff3d62cfc in ?? () from /usr/lib/x86_64-linux-gnu/libX11.so.6
#3  0x00007ffff3d62fcd in _XEventsQueued ()
   from /usr/lib/x86_64-linux-gnu/libX11.so.6
#4  0x00007ffff3d5512d in XPending ()
   from /usr/lib/x86_64-linux-gnu/libX11.so.6
#5  0x00007ffff68485fc in OIS::LinuxMouse::_processXEvents() ()
   from /usr/lib/x86_64-linux-gnu/libOIS-1.3.0.so
#6  0x00007ffff6848982 in OIS::LinuxMouse::capture() ()
   from /usr/lib/x86_64-linux-gnu/libOIS-1.3.0.so
#7  0x0000000000733bd0 in InputEngine::Capture() ()
#8  0x00000000005293ac in RoRFrameListener::frameStarted(Ogre::FrameEvent const&) ()
#9  0x00007ffff74aff2c in Ogre::Root::_fireFrameStarted(Ogre::FrameEvent&) ()
   from /usr/local/lib/libOgreMain.so.1.8.1
#10 0x00007ffff74b17d1 in Ogre::Root::_fireFrameStarted() ()
   from /usr/local/lib/libOgreMain.so.1.8.1
#11 0x00007ffff74b18d9 in Ogre::Root::renderOneFrame() ()
   from /usr/local/lib/libOgreMain.so.1.8.1
#12 0x00000000007695c0 in RoR::MainThread::EnterGameplayLoop() ()
#13 0x000000000076e2e3 in RoR::MainThread::Go() ()
#14 0x00000000005040f7 in main ()
(gdb) 
@Max98

This comment has been minimized.

Show comment
Hide comment
@Max98

Max98 Jan 8, 2015

Contributor

So it's about the mouse handler not being deleted at exit?

Contributor

Max98 commented Jan 8, 2015

So it's about the mouse handler not being deleted at exit?

@Aperion

This comment has been minimized.

Show comment
Hide comment
@Aperion

Aperion Jan 9, 2015

Member

@Max98 this sounds correct, A long time ago there was an issue where if RoR crashed it would turn off auto repeat in linux. This effected me all the time in linux since I stopped debugging instead of exiting properly. Checking just now that seams to be fixed but perhaps there is somethign left over.

Member

Aperion commented Jan 9, 2015

@Max98 this sounds correct, A long time ago there was an issue where if RoR crashed it would turn off auto repeat in linux. This effected me all the time in linux since I stopped debugging instead of exiting properly. Checking just now that seams to be fixed but perhaps there is somethign left over.

@Max98

This comment has been minimized.

Show comment
Hide comment
@Max98

Max98 Jan 10, 2015

Contributor

I see, but i have a question. Why doesn't this happen on windows?

Contributor

Max98 commented Jan 10, 2015

I see, but i have a question. Why doesn't this happen on windows?

@Hiradur

This comment has been minimized.

Show comment
Hide comment
@Hiradur

Hiradur Jan 31, 2015

Contributor

I think Windows handles the mouse listener differently. See this comment from the OGRE tutorials:

//Unattach OIS before window shutdown (very important under Linux)

http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Basic+Tutorial+6#Shutting_down_OIS

I updated the description since the stack trace depends on how the game is exited.

Contributor

Hiradur commented Jan 31, 2015

I think Windows handles the mouse listener differently. See this comment from the OGRE tutorials:

//Unattach OIS before window shutdown (very important under Linux)

http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Basic+Tutorial+6#Shutting_down_OIS

I updated the description since the stack trace depends on how the game is exited.

@Hiradur

This comment has been minimized.

Show comment
Hide comment
@Hiradur

Hiradur Feb 1, 2015

Contributor

This may be caused by RoRFrameListener::shutdown_final():

// RoRFrameListener::shutdown_final() is allways called by main thread.
// Therefore we need no syncing here.
RoR::Application::GetMainThreadLogic()->RequestShutdown();
RoR::Application::GetMainThreadLogic()->RequestExitCurrentLoop();

I got the feeling that these comments are wrong since RoRFrameListener::shutdown_final() is also called by MenuWindow::eventMouseButtonClickExitButton(). OIS gets shut down before the MainThread which calls Capture() once more when OIS is already dead.
Any comment from @only-a-ptr?

Contributor

Hiradur commented Feb 1, 2015

This may be caused by RoRFrameListener::shutdown_final():

// RoRFrameListener::shutdown_final() is allways called by main thread.
// Therefore we need no syncing here.
RoR::Application::GetMainThreadLogic()->RequestShutdown();
RoR::Application::GetMainThreadLogic()->RequestExitCurrentLoop();

I got the feeling that these comments are wrong since RoRFrameListener::shutdown_final() is also called by MenuWindow::eventMouseButtonClickExitButton(). OIS gets shut down before the MainThread which calls Capture() once more when OIS is already dead.
Any comment from @only-a-ptr?

@only-a-ptr

This comment has been minimized.

Show comment
Hide comment
@only-a-ptr

only-a-ptr Feb 2, 2015

Member

@Hiradur
The shutdown code is a mess and I didn't get to clean it yet. Any research/cleanup/fix is welcome.
Time to time, I experience a segfault from OIS joystick subsystem on shutdown. Definitely related
Those comments may be wrong, I forgot to fullltext-search the function, I didn't know it's called from GUI handlers (even though those are invoked on OIS update, by main thread).

IMO correct shutdown architecture would be:

  1. Initiate shutdown by calling Application::GetMainThreadLogic()->RequestExitCurrentLoop();
  2. Move all code from shutdown_final() to main thread and execute it after all loops were terminated.
  3. Eliminate all shutdown() functions everywhere. Only MainThread should handle shutdown sequence.
Member

only-a-ptr commented Feb 2, 2015

@Hiradur
The shutdown code is a mess and I didn't get to clean it yet. Any research/cleanup/fix is welcome.
Time to time, I experience a segfault from OIS joystick subsystem on shutdown. Definitely related
Those comments may be wrong, I forgot to fullltext-search the function, I didn't know it's called from GUI handlers (even though those are invoked on OIS update, by main thread).

IMO correct shutdown architecture would be:

  1. Initiate shutdown by calling Application::GetMainThreadLogic()->RequestExitCurrentLoop();
  2. Move all code from shutdown_final() to main thread and execute it after all loops were terminated.
  3. Eliminate all shutdown() functions everywhere. Only MainThread should handle shutdown sequence.
@Hiradur

This comment has been minimized.

Show comment
Hide comment
@Hiradur

Hiradur Feb 3, 2015

Contributor

Sounds good. Will do this when I got more time.

Contributor

Hiradur commented Feb 3, 2015

Sounds good. Will do this when I got more time.

@Hiradur Hiradur added the Linux label Jun 23, 2015

@Hiradur

This comment has been minimized.

Show comment
Hide comment
@Hiradur

Hiradur Jul 6, 2015

Contributor

Sorry, I totally forgot about this one. Today I realized it doesn't happen with mouse grabbing set to 'dynamically' in RoRConfig.

Contributor

Hiradur commented Jul 6, 2015

Sorry, I totally forgot about this one. Today I realized it doesn't happen with mouse grabbing set to 'dynamically' in RoRConfig.

@Hiradur Hiradur self-assigned this Jul 15, 2015

@Hiradur Hiradur added this to the 0.4.6.0 milestone Oct 24, 2015

@Hiradur

This comment has been minimized.

Show comment
Hide comment
@Hiradur

Hiradur Nov 18, 2015

Contributor

@only-a-ptr
I fixed the segfault but I didn't move the code from RoRFrameListener::shutdown_final() to MainThread. Should I still do this or do you want to do it yourself with your new SimMainThread approach?

Contributor

Hiradur commented Nov 18, 2015

@only-a-ptr
I fixed the segfault but I didn't move the code from RoRFrameListener::shutdown_final() to MainThread. Should I still do this or do you want to do it yourself with your new SimMainThread approach?

@only-a-ptr

This comment has been minimized.

Show comment
Hide comment
@only-a-ptr

only-a-ptr Dec 2, 2015

Member

@Hiradur Please refactor this yourself as you see fit.

My "SimMainThread" project won't be started anytime soon, I have RigEditor(Python) + Powertrain(Lua) + bugfixes on my plate.

Member

only-a-ptr commented Dec 2, 2015

@Hiradur Please refactor this yourself as you see fit.

My "SimMainThread" project won't be started anytime soon, I have RigEditor(Python) + Powertrain(Lua) + bugfixes on my plate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment