Craft icon indicating copy to clipboard operation
Craft copied to clipboard

Immediate segmentation violation

Open WyomingWill opened this issue 11 years ago • 11 comments

Compiled on Ubuntu 12.04, Craft immediately crashes with a segmentation violation. Here is some info (I added the -g flag when compiling):

BOLO: gdb ./craft GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04 Copyright (C) 2012 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 "i686-linux-gnu". For bug reporting instructions, please see: http://bugs.launchpad.net/gdb-linaro/... Reading symbols from /home/me/bin/Craft/craft...done. (gdb) run Starting program: /home/me/bin/Craft/craft [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault. 0x00000000 in ?? () (gdb) bt #0 0x00000000 in ?? () #1 0x08080382 in make_shader (type=35633,

source=0x8489ab8 "#version 120\n\nuniform mat4 matrix;\nuniform vec3 camera;\nuniform float fog_distance;\nuniform int ortho;\n\nattribute vec4 position;\nattribute vec3 normal;\nattribute vec4 uv;\n\nvarying vec2 fragment_uv;\nva"...) at /home/me/bin/Craft/src/util.c:65 #2 0x080805f1 in load_shader (path=0x815d40e "shaders/block_vertex.glsl", type=35633)

at /home/me/bin/Craft/src/util.c:83 #3 load_program (path1=0x815d40e "shaders/block_vertex.glsl", path2=0x815d3f2 "shaders/block_fragment.glsl")

at /home/me/bin/Craft/src/util.c:111 #4 0x0807ace6 in main (argc=1, argv=0xbffff2e4) at /home/me/bin/Craft/src/main.c:2661

(gdb)

I'd love to get this working to do some hobby AI... ;-) Thanks in advance.

WyomingWill avatar Dec 19 '14 23:12 WyomingWill

Could it be because my OpenGL is too old?

BOLO: glxinfo | grep "OpenGL version" OpenGL version string: 1.4 Mesa 9.0

WyomingWill avatar Dec 20 '14 00:12 WyomingWill

@WyomingWill Even though it should work, try updating to Ubuntu 14.04 LTS and its possible that it could be old

dariusc93 avatar Dec 28 '14 08:12 dariusc93

Sorry for the late reply, but I finally got a chance to upgrade to Ubuntu 14.04. Unfortunately, same problem. Here is a trace. Any help would be appreciated!

BOLO: gdb ./craft GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1 Copyright (C) 2014 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 "i686-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 ./craft...done. (gdb) run Starting program: /home/me/bin/Craft/craft [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault. 0x00000000 in ?? () (gdb) bt #0 0x00000000 in ?? () #1 0x0807e292 in make_shader (type=type@entry=35633, source=source@entry=0x8458510 "#version 120\n\nuniform mat4 matrix;\nuniform vec3 camera;\nuniform float fog_distance;\nuniform int ortho;\n\nattribute vec4 position;\nattribute vec3 normal;\nattribute vec4 uv;\n\nvarying vec2 fragment_uv;\nva"...) at /home/me/bin/Craft/src/util.c:65 #2 0x0807e538 in load_shader (path=0x816e385 "shaders/block_vertex.glsl", type=35633) at /home/me/bin/Craft/src/util.c:83 #3 load_program (path1=path1@entry=0x816e385 "shaders/block_vertex.glsl", path2=path2@entry=0x816e369 "shaders/block_fragment.glsl") at /home/me/bin/Craft/src/util.c:111 #4 0x08079a37 in main (argc=1, argv=0xbffff064) at /home/me/bin/Craft/src/main.c:2661 (gdb)

WyomingWill avatar Mar 08 '15 02:03 WyomingWill

Did you happen to build the game in a directory other than the root of the project? I ran into the same problem when I tried to use it like this:

mkdir build
cd build
cmake ..
make
./craft

Running it from the root directory might be the issue Craft-master$ ./build/craft

RyanRiffle avatar Jun 28 '15 14:06 RyanRiffle

I'm not sure what you are suggesting. I followed the directions in his README file.

BOLO: git clone https://github.com/fogleman/Craft.git

BOLO: cd Craft

BOLO: cmake . -- The C compiler identification is GNU 4.9.2 -- The CXX compiler identification is GNU 4.9.2 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Looking for XOpenDisplay in /usr/lib/i386-linux-gnu/libX11.so;/usr/lib/i386-linux-gnu/libXext.so -- Looking for XOpenDisplay in /usr/lib/i386-linux-gnu/libX11.so;/usr/lib/i386-linux-gnu/libXext.so - found -- Looking for gethostbyname -- Looking for gethostbyname - found -- Looking for connect -- Looking for connect - found -- Looking for remove -- Looking for remove - found -- Looking for shmat -- Looking for shmat - found -- Looking for IceConnectionNumber in ICE -- Looking for IceConnectionNumber in ICE - found -- Found X11: /usr/lib/i386-linux-gnu/libX11.so -- Found OpenGL: /usr/lib/i386-linux-gnu/libGL.so
-- Looking for include file pthread.h -- Looking for include file pthread.h - found -- Looking for pthread_create -- Looking for pthread_create - not found -- Looking for pthread_create in pthreads -- Looking for pthread_create in pthreads - not found -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - found -- Found Threads: TRUE
-- Found Doxygen: /usr/bin/doxygen (found version "1.8.6") -- Using X11 for window creation -- Using GLX for context creation -- Looking for glXGetProcAddress -- Looking for glXGetProcAddress - found -- Looking for glXGetProcAddressARB -- Looking for glXGetProcAddressARB - found -- Looking for glXGetProcAddressEXT -- Looking for glXGetProcAddressEXT - not found -- Found CURL: /usr/lib/i386-linux-gnu/libcurl.so (found version "7.35.0") -- Configuring done -- Generating done -- Build files have been written to: /home/wspears/bin/Craft

BOLO: make Scanning dependencies of target glfw [ 2%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/clipboard.c.o [ 5%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/context.c.o [ 8%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/gamma.c.o [ 11%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/init.c.o [ 13%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/input.c.o [ 16%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/joystick.c.o [ 19%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/monitor.c.o [ 22%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/time.c.o [ 25%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/window.c.o [ 27%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/x11_clipboard.c.o [ 30%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/x11_gamma.c.o [ 33%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/x11_init.c.o [ 36%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/x11_joystick.c.o [ 38%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/x11_monitor.c.o [ 41%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/x11_time.c.o [ 44%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/x11_window.c.o [ 47%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/x11_unicode.c.o [ 50%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/glx_context.c.o Linking C static library libglfw3.a [ 50%] Built target glfw Scanning dependencies of target craft [ 52%] Building C object CMakeFiles/craft.dir/src/auth.c.o [ 55%] Building C object CMakeFiles/craft.dir/src/world.c.o [ 58%] Building C object CMakeFiles/craft.dir/src/sign.c.o [ 61%] Building C object CMakeFiles/craft.dir/src/map.c.o [ 63%] Building C object CMakeFiles/craft.dir/src/db.c.o [ 66%] Building C object CMakeFiles/craft.dir/src/cube.c.o [ 69%] Building C object CMakeFiles/craft.dir/src/util.c.o /home/wspears/bin/Craft/src/util.c: In function ‘load_file’: /home/wspears/bin/Craft/src/util.c:35:5: warning: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Wunused-result] fread(data, 1, length, file); ^ [ 72%] Building C object CMakeFiles/craft.dir/src/item.c.o [ 75%] Building C object CMakeFiles/craft.dir/src/ring.c.o [ 77%] Building C object CMakeFiles/craft.dir/src/main.c.o In file included from /home/wspears/bin/Craft/src/main.c:19:0: /home/wspears/bin/Craft/deps/tinycthread/tinycthread.h:221:44: warning: ‘struct timespec’ declared inside parameter list int mtx_timedlock(mtx_t *mtx, const struct timespec *ts); ^ /home/wspears/bin/Craft/deps/tinycthread/tinycthread.h:307:57: warning: ‘struct timespec’ declared inside parameter list int cnd_timedwait(cnd_t *cond, mtx_t *mtx, const struct timespec *ts); ^ /home/wspears/bin/Craft/deps/tinycthread/tinycthread.h:382:58: warning: ‘struct timespec’ declared inside parameter list int thrd_sleep(const struct timespec *time_point, struct timespec *remaining); ^ [ 80%] Building C object CMakeFiles/craft.dir/src/matrix.c.o [ 83%] Building C object CMakeFiles/craft.dir/src/client.c.o [ 86%] Building C object CMakeFiles/craft.dir/deps/glew/src/glew.c.o [ 88%] Building C object CMakeFiles/craft.dir/deps/lodepng/lodepng.c.o [ 91%] Building C object CMakeFiles/craft.dir/deps/noise/noise.c.o [ 94%] Building C object CMakeFiles/craft.dir/deps/sqlite/sqlite3.c.o [ 97%] Building C object CMakeFiles/craft.dir/deps/tinycthread/tinycthread.c.o Linking C executable craft [ 97%] Built target craft Scanning dependencies of target docs [100%] Generating HTML documentation [100%] Built target docs

Then I try to run it in various ways:

BOLO: craft Segmentation fault (core dumped) BOLO: ./craft Segmentation fault (core dumped) BOLO: pwd /home/me/bin/Craft BOLO: cd ../ BOLO: Craft/craft error 78: failed to open file for reading error 78: failed to open file for reading error 78: failed to open file for reading error 78: failed to open file for reading Segmentation fault (core dumped) BOLO: pwd /home/me/bin BOLO: cd ../ BOLO: bin/Craft/craft error 78: failed to open file for reading error 78: failed to open file for reading error 78: failed to open file for reading error 78: failed to open file for reading Segmentation fault (core dumped)

In all cases a black window pops up, and then immediately disappears.

I'm not sure if the error "Looking for glXGetProcAddressEXT - not found" is really an issue or not.

Thanks, Bill

WyomingWill avatar Jul 09 '15 04:07 WyomingWill

Try:

$ rm -r CMakeCache.txt CMakeFiles
$ cmake . -DCMAKE_BUILD_TYPE=DEBUG
$ make
$ gdb ./craft

Then, at GDB's prompt, type:

run

When the program crashes, type:

bt

Post all the output. That should give the precise location of the segfault.

BTW, next time, you can surround things like command output with backticks: three at the top and three at the bottom. It causes GitHub to format it like above, which makes it slightly easier to read. :)

refi64 avatar Jul 09 '15 14:07 refi64

OK! Here you go...

(gdb) run
Starting program: /home/wspears/bin/Craft/craft 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x00000000 in ?? ()
(gdb) bt
#0  0x00000000 in ?? ()
#1  0x0807ef1f in make_shader (type=35633, 
    source=0x847f5f8 "#version 120\n\nuniform mat4 matrix;\nuniform vec3 camera;\nuniform float fog_distance;\nuniform int ortho;\n\nattribute vec4 position;\nattribute vec3 normal;\nattribute vec4 uv;\n\nvarying vec2 fragment_uv;\nva"...)
    at /home/wspears/bin/Craft/src/util.c:65
#2  0x0807f142 in load_shader (path=0x817039d "shaders/block_vertex.glsl", 
    type=35633) at /home/wspears/bin/Craft/src/util.c:83
#3  load_program (path1=0x817039d "shaders/block_vertex.glsl", 
    path2=0x8170381 "shaders/block_fragment.glsl")
    at /home/wspears/bin/Craft/src/util.c:111
#4  0x0807968e in main (argc=1, argv=0xbffff0c4)
    at /home/wspears/bin/Craft/src/main.c:2661
(gdb) 

And thanks for the backtick tip. Nice. Bill

WyomingWill avatar Jul 09 '15 21:07 WyomingWill

@WyomingWill Now I have no clue what's wrong. :(

You can try googling glcreateshader segmentation fault and trying the various solutions.

refi64 avatar Jul 09 '15 23:07 refi64

I suspect my hardware might be too old.

BOLO: glxinfo | grep "OpenGL version"
OpenGL version string: 1.4 Mesa 10.3.2

It appears shaders in OpenGL 1.4 require some extra stuff... But I have to admit I don't know how to fix this.

WyomingWill avatar Jul 10 '15 00:07 WyomingWill

I encountered the same issue but it was due to out of source build. If the sigev is due to that issue then, just run the 'craft' from the source dir with the relative path i.e ./build/craft

udnaan avatar Jun 02 '16 06:06 udnaan

I should have followed up on this. It definitely appears to be that my hardware is too old. I have a G31 graphics controller. According to Wikipedia: "Integrated graphics found on G31 and G33 chipsets, and the derived Q33 and Q35 chipset motherboards. Supports Pixel Shader 2.0 and doesn't support Vertex Shader with OpenGL 1.4 support."

When I ported the code to a laptop with a slightly better graphics board, it fired right up. Same OS. Just slightly better graphics hardware.

So, yeah, 8+ year old hardware seems to be the problem. Thanks everyone, for your comments.

WyomingWill avatar Jun 04 '16 04:06 WyomingWill