Skip to content
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

Crash on OSX on start #6

Closed
dymk opened this issue Dec 10, 2013 · 3 comments
Closed

Crash on OSX on start #6

dymk opened this issue Dec 10, 2013 · 3 comments

Comments

@dymk
Copy link
Contributor

dymk commented Dec 10, 2013

Issued this command to build:

Codeinator:c dymk$ git clone https://github.com/fogleman/Craft.git
Cloning into 'Craft'...
remote: Counting objects: 1133, done.
...
Resolving deltas: 100% (614/614), done.
Checking connectivity... done
Codeinator:c dymk$ cd Craft/
Codeinator:Craft dymk$ mkdir build && cd build
Codeinator:build dymk$ cmake ..
...
-- Build files have been written to: /Users/dymk/code/c/Craft/build
Codeinator:build dymk$ make
...
Linking C executable craft
[100%] Built target craft
Codeinator:build dymk$ ./craft

A window is drawn on the screen for a split second, then:

Codeinator:build dymk$ ./craft
error 78: failed to open file for reading
craft(91572,0x7fff7cccf310) malloc: *** error for object 0x7fff8dc24d6f: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6
Codeinator:build dymk$

OS Version: Mac OS X 10.9

@dymk
Copy link
Contributor Author

dymk commented Dec 10, 2013

Program works as expected when the craft executable is run with the CWD as the root of the project:

./build/craft

A fix would probably be to check if the files that it's trying to access exist before continuing.

@daniel-j-h
Copy link

To provide more information, it's the load_png_texture function that uses and frees the image even if it could not be loaded.

Backtrace:

#0  0x00007ffff62fe119 in raise () from /lib64/libc.so.6
#1  0x00007ffff62ff478 in abort () from /lib64/libc.so.6
#2  0x00007ffff633aaf7 in __libc_message () from /lib64/libc.so.6
#3  0x00007ffff634048e in malloc_printerr () from /lib64/libc.so.6
#4  0x000000000041b1a6 in load_png_texture (file_name=file_name@entry=0x4ccb2a "texture.png") at ../util.c:582
#5  0x0000000000411d61 in main (argc=1, argv=0x7fffffffddf8) at ../main.c:858

See: https://github.com/fogleman/Craft/blob/7e2497d87440ffd3a914076b842f972a2117771b/util.c#L580-582

And after this, the load_shader function has the same problems. Backtrace:

#0  0x00007ffff6338f6c in fseek () from /lib64/libc.so.6
#1  0x0000000000418f10 in load_file (path=<optimized out>) at ../util.c:33
#2  0x00000000004191fc in load_shader (path=<optimized out>, type=35633) at ../util.c:69
#3  load_program (path1=path1@entry=0x4ccb52 "shaders/block_vertex.glsl", path2=path2@entry=0x4ccb36 "shaders/block_fragment.glsl") at ../util.c:98
#4  0x0000000000411d70 in main (argc=1, argv=0x7fffffffddf8) at ../main.c:860

See:

Craft/util.c

Line 68 in 7e2497d

GLuint load_shader(GLenum type, const char *path) {

(Maybe there are more issues, but I have not checked it further)

@daniloegea
Copy link

The problem is that the program search the files in the local dir. My patch fix this problem and enable you to install "craft" where you want.

#25

callmehgav referenced this issue in chongwick/Craft Apr 7, 2020
Update backlog.md with daniels tasks
AlexPanacea pushed a commit to AlexPanacea/Craft that referenced this issue Jan 11, 2022
DS_2_3 (Doxy standards) and DS_2_4 (gitignore update)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants