fogleman/Craft

Segmentation Fault upon closing the game

usernamefreaks opened this issue · 4 comments

I'm running an Ubuntu 18.04.2 VM from VMware. Every time I close the game window, the command line always displays Segmentation fault (core dumped). It doesn't affect the quality of the gameplay, however it does hint at the existence of memory errors in the code.

I've noticed this. It happens less frequently, if at all, when the game has finished loading all the chunks in view. I wonder if it is a NULL dereference in a worker.

We found it to be caused by the outdated GLFW library. (It was a segfault inside GLFW.) This has since been patched in newer versions of GLFW, so updating it solves the issue.

Cool, nice to know!

Got this on my Ubuntu 18.04 install too, made a gdb backtrace (built with -DCMAKE_BUILD_TYPE=Debug in cmake command line):

(gdb) r
Starting program: /home/juozas/test/Craft/craft 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffec665700 (LWP 12735)]
[New Thread 0x7fffebe64700 (LWP 12736)]
[New Thread 0x7fffeb663700 (LWP 12737)]
[New Thread 0x7fffeae62700 (LWP 12738)]
[New Thread 0x7fffea661700 (LWP 12739)]
[Thread 0x7fffea661700 (LWP 12739) exited]

Thread 1 "craft" received signal SIGSEGV, Segmentation fault.
__GI___libc_free (mem=0x55a49d90) at malloc.c:3103
3103	malloc.c: No such file or directory.
(gdb) thread apply all bt

Thread 5 (Thread 0x7fffeae62700 (LWP 12738)):
#0  0x00007ffff6eda9f3 in futex_wait_cancelable (private=<optimized out>, expected=0, futex_word=0x5555558bb308 <model+968>) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
#1  __pthread_cond_wait_common (abstime=0x0, mutex=0x5555558bb2b8 <model+888>, cond=0x5555558bb2e0 <model+928>) at pthread_cond_wait.c:502
#2  __pthread_cond_wait (cond=0x5555558bb2e0 <model+928>, mutex=0x5555558bb2b8 <model+888>) at pthread_cond_wait.c:655
#3  0x0000555555673459 in cnd_wait (cond=<optimized out>, mtx=<optimized out>) at /home/juozas/test/Craft/deps/tinycthread/tinycthread.c:289
#4  0x000055555559e29b in worker_run (arg=arg@entry=0x5555558bb2a8 <model+872>) at /home/juozas/test/Craft/src/main.c:1437
#5  0x00005555556732b7 in _thrd_wrapper_function (aArg=<optimized out>) at /home/juozas/test/Craft/deps/tinycthread/tinycthread.c:346
#6  0x00007ffff6ed46db in start_thread (arg=0x7fffeae62700) at pthread_create.c:463
#7  0x00007ffff5c0488f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 4 (Thread 0x7fffeb663700 (LWP 12737)):
#0  0x00007ffff6eda9f3 in futex_wait_cancelable (private=<optimized out>, expected=0, futex_word=0x5555558bb1e8 <model+680>) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
#1  __pthread_cond_wait_common (abstime=0x0, mutex=0x5555558bb198 <model+600>, cond=0x5555558bb1c0 <model+640>) at pthread_cond_wait.c:502
#2  __pthread_cond_wait (cond=0x5555558bb1c0 <model+640>, mutex=0x5555558bb198 <model+600>) at pthread_cond_wait.c:655
#3  0x0000555555673459 in cnd_wait (cond=<optimized out>, mtx=<optimized out>) at /home/juozas/test/Craft/deps/tinycthread/tinycthread.c:289
#4  0x000055555559e29b in worker_run (arg=arg@entry=0x5555558bb188 <model+584>) at /home/juozas/test/Craft/src/main.c:1437
#5  0x00005555556732b7 in _thrd_wrapper_function (aArg=<optimized out>) at /home/juozas/test/Craft/deps/tinycthread/tinycthread.c:346
#6  0x00007ffff6ed46db in start_thread (arg=0x7fffeb663700) at pthread_create.c:463
#7  0x00007ffff5c0488f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 3 (Thread 0x7fffebe64700 (LWP 12736)):
#0  0x00007ffff6eda9f3 in futex_wait_cancelable (private=<optimized out>, expected=0, futex_word=0x5555558bb0c8 <model+392>) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
#1  __pthread_cond_wait_common (abstime=0x0, mutex=0x5555558bb078 <model+312>, cond=0x5555558bb0a0 <model+352>) at pthread_cond_wait.c:502
#2  __pthread_cond_wait (cond=0x5555558bb0a0 <model+352>, mutex=0x5555558bb078 <model+312>) at pthread_cond_wait.c:655
#3  0x0000555555673459 in cnd_wait (cond=<optimized out>, mtx=<optimized out>) at /home/juozas/test/Craft/deps/tinycthread/tinycthread.c:289
#4  0x000055555559e29b in worker_run (arg=arg@entry=0x5555558bb068 <model+296>) at /home/juozas/test/Craft/src/main.c:1437
#5  0x00005555556732b7 in _thrd_wrapper_function (aArg=<optimized out>) at /home/juozas/test/Craft/deps/tinycthread/tinycthread.c:346
#6  0x00007ffff6ed46db in start_thread (arg=0x7fffebe64700) at pthread_create.c:463
#7  0x00007ffff5c0488f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 2 (Thread 0x7fffec665700 (LWP 12735)):
#0  0x00007ffff6eda9f3 in futex_wait_cancelable (private=<optimized out>, expected=0, futex_word=0x5555558bafa8 <model+104>) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
#1  __pthread_cond_wait_common (abstime=0x0, mutex=0x5555558baf58 <model+24>, cond=0x5555558baf80 <model+64>) at pthread_cond_wait.c:502
#2  __pthread_cond_wait (cond=0x5555558baf80 <model+64>, mutex=0x5555558baf58 <model+24>) at pthread_cond_wait.c:655
#3  0x0000555555673459 in cnd_wait (cond=<optimized out>, mtx=<optimized out>) at /home/juozas/test/Craft/deps/tinycthread/tinycthread.c:289
#4  0x000055555559e29b in worker_run (arg=arg@entry=0x5555558baf48 <model+8>) at /home/juozas/test/Craft/src/main.c:1437
#5  0x00005555556732b7 in _thrd_wrapper_function (aArg=<optimized out>) at /home/juozas/test/Craft/deps/tinycthread/tinycthread.c:346
#6  0x00007ffff6ed46db in start_thread (arg=0x7fffec665700) at pthread_create.c:463
#7  0x00007ffff5c0488f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 1 (Thread 0x7ffff7fae780 (LWP 12731)):
#0  __GI___libc_free (mem=0x55a49d90) at malloc.c:3103
#1  0x000055555567557c in _glfwFreeMonitor (monitor=0x555555a49e00) at /home/juozas/test/Craft/deps/glfw/src/monitor.c:185
#2  0x00005555556755bc in _glfwFreeMonitors (monitors=0x555555a49db0, count=<optimized out>) at /home/juozas/test/Craft/deps/glfw/src/monitor.c:211
#3  0x00005555556745c0 in glfwTerminate () at /home/juozas/test/Craft/deps/glfw/src/init.c:162
#4  0x00005555555943fe in main (argc=<optimized out>, argv=<optimized out>) at /home/juozas/test/Craft/src/main.c:2960