OpenTomb icon indicating copy to clipboard operation
OpenTomb copied to clipboard

Segfault at startup

Open monreal opened this issue 7 years ago • 7 comments

I get a segfault when trying to start opentomb with current git master as well as the latest "release" (88fbfd3) compiled on Fedora Linux:

Thread 1 "OpenTomb" received signal SIGSEGV, Segmentation fault. strlen () at ../sysdeps/x86_64/strlen.S:106 106 movdqu (%rax), %xmm4 (gdb) bt #0 strlen () at ../sysdeps/x86_64/strlen.S:106 #1 0x000000000047b78a in InitGLExtFuncs () #2 0x00000000005045b3 in Engine_InitGL() () #3 0x000000000050422d in Engine_Start(int, char**) () #4 0x0000000000516ba5 in main ()

monreal avatar Sep 15 '17 11:09 monreal

Looks like this could be the culprit:

    const char* buf = (const char*)qglGetString(GL_EXTENSIONS);
    size_t buf_size = strlen(buf) + 1;
    engine_gl_ext_str = (char*)malloc(buf_size);
    strncpy(engine_gl_ext_str, buf, buf_size);

But it doesn't segfault on me.

EDIT: As far as remember the strings should not overlap and this is especially important on 64-bit architectures (I use 32-bit Fedora on 64-bit CPU).

EDIT2: Looks like it segfaults inside strlen which is weird.

EDIT3: Some drivers have setting to truncate extension string. Make sure it does NOT truncated.

vvs- avatar Sep 15 '17 12:09 vvs-

I have to add nullptr check for returned string...

TeslaRus avatar Sep 16 '17 20:09 TeslaRus

This still happens to me on Arch linux as of commit 11402da92668c42361ce32b943b35f9a00852f1

IMbackK avatar Oct 29 '17 15:10 IMbackK

Hi, I tried last commit 56cd0547c4ca1ef11125cf639b6bea57dfa2abb0 right now on Xubuntu 17.10 64 bits and got a segfault on game start. I rebuilded game with debug information (using CMake -DCMAKE_BUILD_TYPE=Debug) and here is the debugger output (if it can be of some help) :

ar@ar-i7:~/Documents/OpenTomb$ gdb --args build_debug/OpenTomb -config config_tr1.lua -autoexec autoexec_tr1.lua 
GNU gdb (Ubuntu 8.0.1-0ubuntu1) 8.0.1
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from build_debug/OpenTomb...done.
(gdb) r
Starting program: /home/ar/Documents/OpenTomb/build_debug/OpenTomb -config config_tr1.lua -autoexec autoexec_tr1.lua
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffed108700 (LWP 7069)]
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for 4294967295, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for 4294967295, skipping unlock
[Thread 0x7fffed108700 (LWP 7069) exited]
[New Thread 0x7fffeca70700 (LWP 7070)]
[Thread 0x7fffeca70700 (LWP 7070) exited]
[New Thread 0x7fffeca70700 (LWP 7071)]
[New Thread 0x7fffed087700 (LWP 7072)]
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: cHRM chunk does not match sRGB

Thread 1 "OpenTomb" received signal SIGSEGV, Segmentation fault.
0x00005555555d46a6 in AVL_SearchNode (header=0x0, key=4294967295) at /home/ar/Documents/OpenTomb/src/core/avl.c:84
84	    avl_node_p current = header->root;
(gdb) bt
#0  0x00005555555d46a6 in AVL_SearchNode (header=0x0, key=4294967295) at /home/ar/Documents/OpenTomb/src/core/avl.c:84
#1  0x00005555556acabe in World_GetEntityByID (id=4294967295) at /home/ar/Documents/OpenTomb/src/world.cpp:538
#2  0x0000555555697819 in Game_Frame (time=0) at /home/ar/Documents/OpenTomb/src/game.cpp:664
#3  0x000055555568a745 in Engine_MainLoop () at /home/ar/Documents/OpenTomb/src/engine.cpp:865
#4  0x000055555569c3b8 in main (argc=5, argv=0x7fffffffdfc8) at /home/ar/Documents/OpenTomb/src/main_SDL.cpp:15

RICCIARDI-Adrien avatar Jan 30 '18 18:01 RICCIARDI-Adrien

thanks for report looks like no level loaded, so avl header is nullptr... I will add nullptr header check

TeslaRus avatar Jan 31 '18 06:01 TeslaRus

fixed in https://github.com/opentomb/OpenTomb/commit/96f9d84adac4a926bc59eeacfad6652467d7dd2a

TeslaRus avatar Jan 31 '18 16:01 TeslaRus

I confirm it works on commit 96f9d84adac4a926bc59eeacfad6652467d7dd2a.

RICCIARDI-Adrien avatar Jan 31 '18 17:01 RICCIARDI-Adrien