MegaGlest / megaglest-source

MegaGlest real-time strategy game engine (cross-platform, 3-d)
http://megaglest.org/
355 stars 90 forks source link

MG crashes when changing language in optionscreen #116

Closed titiger closed 7 years ago

titiger commented 8 years ago

Reproduce: change language in option screen press save

more details in forum: https://forum.megaglest.org/index.php?topic=9807.0

tomreyn commented 8 years ago

I just reproduced this bug on Windows 10 (Intel graphics):

The only possibly useful debugging output is: font->getTextHandler() == NULL(5)

softcoder commented 8 years ago

Is this still reproducible with the latest git build? I tried reproducing in windows 7 and it did not crash on language change.

IsshMG commented 7 years ago

I tested this and it crashes every time you change the language in options menu. Once you save the new language, the game crashes. When you restart the game, the new language appears. The change works but the game crashes in the process.

http://i.imgur.com/VW20r48.png

filux commented 7 years ago

There are at least two possible output types, so look to the end.

First type:

Wed Dec 14 22:11:29 CET 2016 [code]

$ ./megaglest
megaglest v3.12-dev
Compiled using: GNUC: 60200 [64bit] platform: Linux-X64 endianness: little
GIT: [Rev: 5543.c741c67] - using STREFLOP [SSE] - [no-denormals]
Error saved to logfile [/home/filux/.megaglest/error.log]
*ERROR* [2016-12-14 22:11:41] In [source/glest_game/main/main.cpp::handleRuntimeError Line: 646] [font->getTextHandler() == NULL (5) text = <
Stack Trace:
mk/linux/megaglest:Shared::Platform::megaglest_runtime_error::megaglest_runtime_error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)address [0x55a5d5244bfc] line: 0
mk/linux/megaglest:Glest::Game::Renderer::getCentered3DPos(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Shared::Graphics::Font3D*, Shared::Graphics::Vec2<float>&, int, int, bool, bool)address [0x55a5d4d99d4b] line: 0
mk/linux/megaglest:Glest::Game::Renderer::renderTextBoundingBox3D(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Shared::Graphics::Font3D*, Shared::Graphics::Vec4<float> const&, int, int, int, int, bool, bool, bool, int, int)address [0x55a5d4d9a5d9] line: 0
mk/linux/megaglest:Glest::Game::Renderer::renderButton(Glest::Game::GraphicButton*, Shared::Graphics::Vec4<float> const*, bool*)address [0x55a5d4d9a94f] line: 0
mk/linux/megaglest:Glest::Game::Renderer::renderListBox(Glest::Game::GraphicListBox*)address [0x55a5d4da1613] line: 0
mk/linux/megaglest:Glest::Game::MenuStateOptions::render()address [0x55a5d4f5fc85] line: 0
mk/linux/megaglest:Glest::Game::MainMenu::render()address [0x55a5d4e47842] line: 0
mk/linux/megaglest:Glest::Game::Program::loopWorker()address [0x55a5d4e42ac9] line: 0
mk/linux/megaglest:Glest::Game::glestMain(int, char**)address [0x55a5d4e2da65] line: 0
mk/linux/megaglest:Glest::Game::glestMainSEHWrapper(int, char**)address [0x55a5d4e35034] line: 0
/lib/x86_64-linux-gnu/libc.so.6:__libc_start_main()address [0x7f36d41b82b1] line: 0
mk/linux/megaglest:_start()address [0x55a5d4c5c68a] line: 0
] gameInitialized = 1, program = 0x55a5d78998c0

=====================================

** Already in error handler exiting error rendering, msg [font->getTextHandler() == NULL (5) text = <
Stack Trace:
mk/linux/megaglest:Shared::Platform::megaglest_runtime_error::megaglest_runtime_error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)address [0x55a5d5244bfc] line: 0
mk/linux/megaglest:Glest::Game::Renderer::getCentered3DPos(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Shared::Graphics::Font3D*, Shared::Graphics::Vec2<float>&, int, int, bool, bool)address [0x55a5d4d99d4b] line: 0
mk/linux/megaglest:Glest::Game::Renderer::renderTextBoundingBox3D(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Shared::Graphics::Font3D*, Shared::Graphics::Vec4<float> const&, int, int, int, int, bool, bool, bool, int, int)address [0x55a5d4d9a5d9] line: 0
mk/linux/megaglest:Glest::Game::Renderer::renderButton(Glest::Game::GraphicButton*, Shared::Graphics::Vec4<float> const*, bool*)address [0x55a5d4d9a94f] line: 0
mk/linux/megaglest:Glest::Game::Renderer::renderListBox(Glest::Game::GraphicListBox*)address [0x55a5d4da1613] line: 0
mk/linux/megaglest:Glest::Game::MenuStateOptions::render()address [0x55a5d4f5fc85] line: 0
mk/linux/megaglest:Glest::Game::MainMenu::render()address [0x55a5d4e47842] line: 0
mk/linux/megaglest:Glest::Game::Program::loopWorker()address [0x55a5d4e42ac9] line: 0
mk/linux/megaglest:Glest::Game::ExceptionHandler::handleRuntimeError(char const*, bool)address [0x55a5d4e19d25] line: 0
mk/linux/megaglest:Glest::Game::glestMain(int, char**)address [0x55a5d4e280c2] line: 0
mk/linux/megaglest:Glest::Game::glestMainSEHWrapper(int, char**)address [0x55a5d4e35034] line: 0
/lib/x86_64-linux-gnu/libc.so.6:__libc_start_main()address [0x7f36d41b82b1] line: 0
mk/linux/megaglest:_start()address [0x55a5d4c5c68a] line: 0
]
Waiting for the following threads to exit [1]:
Thread index: 0 ptr [0x55a5d7b08db0] isBaseThread: 1, Name: [program.cpp_877]
Waiting for the following threads to exit [1]:
Thread index: 0 ptr [0x55a5d7b08db0] isBaseThread: 1, Name: [program.cpp_877]
Waiting for the following threads to exit [1]:
Thread index: 0 ptr [0x55a5d7b08db0] isBaseThread: 1, Name: [program.cpp_877]
Waiting for the following threads to exit [1]:
Thread index: 0 ptr [0x55a5d7b08db0] isBaseThread: 1, Name: [program.cpp_877]
Waiting for the following threads to exit [1]:
Thread index: 0 ptr [0x55a5d7b08db0] isBaseThread: 1, Name: [program.cpp_877]
Waiting for the following threads to exit [1]:
Thread index: 0 ptr [0x55a5d7b08db0] isBaseThread: 1, Name: [program.cpp_877]
Waiting for the following threads to exit [1]:
Thread index: 0 ptr [0x55a5d7b08db0] isBaseThread: 1, Name: [program.cpp_877]
Waiting for the following threads to exit [1]:
Thread index: 0 ptr [0x55a5d7b08db0] isBaseThread: 1, Name: [program.cpp_877]
Waiting for the following threads to exit [1]:
Thread index: 0 ptr [0x55a5d7b08db0] isBaseThread: 1, Name: [program.cpp_877]
Waiting for the following threads to exit [1]:
Thread index: 0 ptr [0x55a5d7b08db0] isBaseThread: 1, Name: [program.cpp_877]

[/code] [code]

$ gdb -q -n -ex "bt" -batch ./megaglest ./core
[New LWP 23500]
[New LWP 23506]
[New LWP 23507]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `mk/l'.
Program terminated with signal SIGABRT, Aborted.
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:58
[Current thread is 1 (Thread 0x7f36d888a6c0 (LWP 23500))]
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:58
#1  0x00007f36d41cc40a in __GI_abort () at abort.c:89
#2  0x000055a5d4e19b02 in Glest::Game::ExceptionHandler::handleRuntimeError (msg=<optimized out>, getStackTraceString=<optimized out>) at source/glest_game/main/main.cpp:773
#3  0x000055a5d4e280c2 in Glest::Game::glestMain (argc=<optimized out>, argv=<optimized out>) at source/glest_game/main/main.cpp:5769
#4  0x000055a5d4e35034 in Glest::Game::glestMainSEHWrapper (argc=1, argv=0x7ffd521141a8) at source/glest_game/main/main.cpp:5972
#5  0x00007f36d41b82b1 in __libc_start_main (main=0x55a5d4c59810 <main(int, char**)>, argc=1, argv=0x7ffd521141a8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffd52114198) at ../csu/libc-start.c:291
#6  0x000055a5d4c5c68a in _start () at source/glest_game/main/main.cpp:6061

[/code] OS info. [Debian GNU/Linux testing (stretch)], Arch.[x86_64], Dir.[mk/linux]

Second type:

Wed Dec 14 22:16:22 CET 2016 [code]

$ ./megaglest
megaglest v3.12-dev
Compiled using: GNUC: 60200 [64bit] platform: Linux-X64 endianness: little
GIT: [Rev: 5543.c741c67] - using STREFLOP [SSE] - [no-denormals]
In [source/glest_game/main/main.cpp::handleSIGSEGV Line: 5874] Error detected: signal 11:
Error saved to logfile [/home/filux/.megaglest/error.log]

[/code] [code]

[2016-12-14 22:16:32] Runtime Error information:
======================================================
In [source/glest_game/main/main.cpp::handleSIGSEGV Line: 5874] Error detected: signal 11:

Stack Trace:
mk/linux/megaglest:Glest::Game::ExceptionHandler::handleRuntimeError(char const*, bool)address [0x55f8ac414cbd] line: 0
mk/linux/megaglest:Glest::Game::handleSIGSEGV(int)address [0x55f8ac415201] line: 0
/lib/x86_64-linux-gnu/libc.so.6:()address [0x7f51525bf040] line: 0
mk/linux/megaglest:Glest::Game::Renderer::getCentered3DPos(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Shared::Graphics::Font3D*, Shared::Graphics::Vec2<float>&, int, int, bool, bool)address [0x55f8ac394b5e] line: 0
mk/linux/megaglest:Glest::Game::Renderer::renderTextBoundingBox3D(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Shared::Graphics::Font3D*, Shared::Graphics::Vec4<float> const&, int, int, int, int, bool, bool, bool, int, int)address [0x55f8ac3955d9] line: 0
mk/linux/megaglest:Glest::Game::Renderer::renderButton(Glest::Game::GraphicButton*, Shared::Graphics::Vec4<float> const*, bool*)address [0x55f8ac39594f] line: 0
mk/linux/megaglest:Glest::Game::Renderer::renderListBox(Glest::Game::GraphicListBox*)address [0x55f8ac39c613] line: 0
mk/linux/megaglest:Glest::Game::MenuStateOptions::render()address [0x55f8ac55ac85] line: 0
mk/linux/megaglest:Glest::Game::MainMenu::render()address [0x55f8ac442842] line: 0
mk/linux/megaglest:Glest::Game::Program::loopWorker()address [0x55f8ac43dac9] line: 0
mk/linux/megaglest:Glest::Game::glestMain(int, char**)address [0x55f8ac428a65] line: 0
mk/linux/megaglest:Glest::Game::glestMainSEHWrapper(int, char**)address [0x55f8ac430034] line: 0
/lib/x86_64-linux-gnu/libc.so.6:__libc_start_main()address [0x7f51525ac2b1] line: 0
mk/linux/megaglest:_start()address [0x55f8ac25768a] line: 0

[/code] [code]

$ gdb -q -n -ex "bt" -batch ./megaglest ./core
[New LWP 23627]
[New LWP 23628]
[New LWP 23629]
[New LWP 23634]
[New LWP 23635]
[New LWP 23630]
[New LWP 23631]
[New LWP 23633]
[New LWP 23636]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `mk/l'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  Glest::Game::Renderer::getCentered3DPos (this=this@entry=0x55f8acc9ad00 <Glest::Game::Renderer::getInstance()::renderer>, text=..., font=font@entry=0x55f8ade05a80, pos=..., w=w@entry=22, h=h@entry=22, centeredW=true, centeredH=true) at source/glest_game/graphics/renderer.cpp:2870
2870            float lineWidth = (font->getTextHandler()->Advance(text.c_str()) * ::Shared::Graphics::Font::scaleFontValue);
[Current thread is 1 (Thread 0x7f5156c7e6c0 (LWP 23627))]
#0  Glest::Game::Renderer::getCentered3DPos (this=this@entry=0x55f8acc9ad00 <Glest::Game::Renderer::getInstance()::renderer>, text="<", font=font@entry=0x55f8ade05a80, pos=..., w=w@entry=22, h=h@entry=22, centeredW=true, centeredH=true) at source/glest_game/graphics/renderer.cpp:2870
#1  0x000055f8ac3955d9 in Glest::Game::Renderer::renderTextBoundingBox3D (this=this@entry=0x55f8acc9ad00 <Glest::Game::Renderer::getInstance()::renderer>, text="<", font=0x55f8ade05a80, color=..., x=x@entry=400, y=y@entry=650, w=22, h=22, centeredW=true, centeredH=true, editModeEnabled=false, maxEditWidth=-1, maxEditRenderWidth=-1) at source/glest_game/graphics/renderer.cpp:3012
#2  0x000055f8ac39594f in Glest::Game::Renderer::renderButton (this=this@entry=0x55f8acc9ad00 <Glest::Game::Renderer::getInstance()::renderer>, button=button@entry=0x55f8aea21e50, fontColorOverride=fontColorOverride@entry=0x0, lightedOverride=lightedOverride@entry=0x0) at source/glest_game/graphics/renderer.cpp:3435
#3  0x000055f8ac39c613 in Glest::Game::Renderer::renderListBox (this=this@entry=0x55f8acc9ad00 <Glest::Game::Renderer::getInstance()::renderer>, listBox=listBox@entry=0x55f8aea21dc0) at source/glest_game/graphics/renderer.cpp:3769
#4  0x000055f8ac55ac85 in Glest::Game::MenuStateOptions::render (this=0x55f8aea21ac0) at source/glest_game/menu/menu_state_options.cpp:1078
#5  0x000055f8ac442842 in Glest::Game::MainMenu::render (this=0x55f8aea30130) at source/glest_game/menu/main_menu.cpp:192
#6  0x000055f8ac43dac9 in Glest::Game::Program::loopWorker (this=0x55f8add19b20) at source/glest_game/main/program.cpp:449
#7  0x000055f8ac414d25 in Glest::Game::ExceptionHandler::handleRuntimeError (msg=<optimized out>, getStackTraceString=<optimized out>) at source/glest_game/main/main.cpp:685
#8  0x000055f8ac415201 in Glest::Game::handleSIGSEGV (sig=<optimized out>) at source/glest_game/main/main.cpp:5878
#9  <signal handler called>
#10 Glest::Game::Renderer::getCentered3DPos (this=this@entry=0x55f8acc9ad00 <Glest::Game::Renderer::getInstance()::renderer>, text="<", font=font@entry=0x55f8ade05a80, pos=..., w=w@entry=22, h=h@entry=22, centeredW=true, centeredH=true) at source/glest_game/graphics/renderer.cpp:2870
#11 0x000055f8ac3955d9 in Glest::Game::Renderer::renderTextBoundingBox3D (this=this@entry=0x55f8acc9ad00 <Glest::Game::Renderer::getInstance()::renderer>, text="<", font=0x55f8ade05a80, color=..., x=x@entry=400, y=y@entry=650, w=22, h=22, centeredW=true, centeredH=true, editModeEnabled=false, maxEditWidth=-1, maxEditRenderWidth=-1) at source/glest_game/graphics/renderer.cpp:3012
#12 0x000055f8ac39594f in Glest::Game::Renderer::renderButton (this=this@entry=0x55f8acc9ad00 <Glest::Game::Renderer::getInstance()::renderer>, button=button@entry=0x55f8aea21e50, fontColorOverride=fontColorOverride@entry=0x0, lightedOverride=lightedOverride@entry=0x0) at source/glest_game/graphics/renderer.cpp:3435
#13 0x000055f8ac39c613 in Glest::Game::Renderer::renderListBox (this=this@entry=0x55f8acc9ad00 <Glest::Game::Renderer::getInstance()::renderer>, listBox=listBox@entry=0x55f8aea21dc0) at source/glest_game/graphics/renderer.cpp:3769
#14 0x000055f8ac55ac85 in Glest::Game::MenuStateOptions::render (this=0x55f8aea21ac0) at source/glest_game/menu/menu_state_options.cpp:1078
#15 0x000055f8ac442842 in Glest::Game::MainMenu::render (this=0x55f8aea30130) at source/glest_game/menu/main_menu.cpp:192
#16 0x000055f8ac43dac9 in Glest::Game::Program::loopWorker (this=0x55f8add19b20) at source/glest_game/main/program.cpp:449
#17 0x000055f8ac428a65 in Glest::Game::glestMain (argc=<optimized out>, argv=<optimized out>) at source/glest_game/main/main.cpp:5708
#18 0x000055f8ac430034 in Glest::Game::glestMainSEHWrapper (argc=1, argv=0x7fff2bff90c8) at source/glest_game/main/main.cpp:5972
#19 0x00007f51525ac2b1 in __libc_start_main (main=0x55f8ac254810 <main(int, char**)>, argc=1, argv=0x7fff2bff90c8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fff2bff90b8) at ../csu/libc-start.c:291
#20 0x000055f8ac25768a in _start ()

[/code] OS info. [Debian GNU/Linux testing (stretch)], Arch.[x86_64], Dir.[mk/linux]

titiger commented 7 years ago

I looked at this a bit more lately and I managed to get the same crash on linux too. But I was not able to reproduce it again. I think its somehow a timing problem too when setting the font given for the new language. I also tried to not render for a second to give more time to load the font somehow, but this did not help. Problem is raised by loading/reloading the font somehow

void MenuStateOptions::saveConfig() line 1129 => void Lang::loadGameStrings() line 188 => void CoreData::loadFonts() line 1267 and following is what causes the problem somehow. void Font::setType(string typeX11, string typeGeneric, string typeGenericFamily) line 257

this somehow ends without set textHandler in Metrics which causes the crash later.....

I forgot to add my linux stacktrace:

tscharn@p2x4:~/gitglest/mk/linux$ ./megaglest
megaglest v3.12-dev
Compiled using: GNUC: 40804 [64bit] platform: Linux-X64 endianness: little
GIT: [Rev: 5541.7a1a28f] - using STREFLOP [SSE] - [no-denormals]
Error saved to logfile [/home/tscharn/.megaglest/error.log]
*ERROR* [2016-12-13 00:43:05] In [/home/tscharn/gitglest/source/glest_game/main/main.cpp::handleRuntimeError Line: 646] [font->getTextHandler() == NULL (5) text = <
Stack Trace:
./megaglest:Shared::Platform::megaglest_runtime_error::megaglest_runtime_error(std::string const&, bool)address [0xb0cd7d] line: 346
./megaglest:Glest::Game::Renderer::getCentered3DPos(std::string const&, Shared::Graphics::Font3D*, Shared::Graphics::Vec2<float>&, int, int, bool, bool)address [0x62558e] line: 2867
./megaglest:Glest::Game::Renderer::renderTextBoundingBox3D(std::string const&, Shared::Graphics::Font3D*, Shared::Graphics::Vec4<float> const&, int, int, int, int, bool, bool, bool, int, int)address [0x625fd2] line: 3012
./megaglest:Glest::Game::Renderer::renderButton(Glest::Game::GraphicButton*, Shared::Graphics::Vec4<float> const*, bool*)address [0x6263bc] line: 3454
./megaglest:Glest::Game::Renderer::renderListBox(Glest::Game::GraphicListBox*)address [0x630c0c] line: 3770
./megaglest:Glest::Game::MenuStateOptions::render()address [0x750b7c] line: 1092
./megaglest:Glest::Game::MainMenu::render()address [0x807e4b] line: 194
./megaglest:Glest::Game::Program::loopWorker()address [0x6d04e0] line: 451
./megaglest:Glest::Game::glestMain(int, char**)address [0x6bb4a3] line: 5708
./megaglest:Glest::Game::glestMainSEHWrapper(int, char**)address [0x6c1dd6] line: 5974
/lib/x86_64-linux-gnu/libc.so.6:__libc_start_main()address [0x7f6af1277f45] line: 0
./megaglest() [0x4f016a]address [0x4f016a]
] gameInitialized = 1, program = 0x2619e40
andy5995 commented 7 years ago

I'm able to reproduce this every time. Here's how:

  1. options menu
  2. switch to the video tab
  3. switch to the language tab
  4. I change the language
  5. save
  6. crash

How to not crash:

  1. options menu
  2. remain on the language tab (without switching to other tabs)
  3. change language
  4. save
  5. no crash

MG self-build GIT: [Rev: 5568.f3c436b6]

I'm using Debian stretch/testing.

andy5995 commented 7 years ago

Here's my terminal output, which I think matches with the above stacktraces:

http://pastebin.com/RHH8pxrB

softcoder commented 7 years ago

Please verify this is now fixed everyone.

andy5995 commented 7 years ago

I can't reproduce it anymore (seems fixed).