shinyquagsire23 / makefst

CDN FST packer and packager for Wii U homebrew
MIT License
13 stars 0 forks source link

memory allocation error #2

Closed coen22 closed 7 years ago

coen22 commented 7 years ago

At this point in the code, the program exits with error abort trap: 6

//Strip path from contents strcpy(out_dirs[i], strstr(out_dirs[i], dir) + strlen(dir) + 1);

I compiled it on mac, after creating the makefile with cmake

CreeperMario commented 7 years ago

What does your directory tree look like? I ask this because I was getting segmentation faults due to there being .DS_Store files within my code and meta folders.

coen22 commented 7 years ago

makefst [args] dir/ and then I have dir/code, dir/meta, and dir/content I'll check if there is any hidden files

coen22 commented 7 years ago

No, not a single hidden file

CreeperMario commented 7 years ago

Not sure if you're still looking, but I just discovered the same issue. In this case, I would assume that you built makefst using the Xcode Command Line tools.

After learning how to debug software using the LLVM debugger, I found the issue.

The function "strcpy" takes a string from a source buffer and copies it to a destination buffer. In this case, the source and destination buffers overlap, which according to the International Organisation for Standardization, is "undefined behaviour."

On Linux (and probably Windows) this still works, because the source buffer starts after the destination buffer, and so won't cause any issues.

But Apple's implementation of the C standard library detects that the buffers overlap, and aborts.

I will push a fork that fixes this issue shortly, however I'll need someone on a Linux/Windows system to check that my changes still work.