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

vgm2x fails to compile on macOS due to missing PATH_MAX and crashes when defined manually #5

Open
donluca opened this issue Oct 20, 2024 · 2 comments

Comments

@donluca
Copy link

donluca commented Oct 20, 2024

When compiling vgm2x on macOS, the compilation fails due to undefined PATH_MAX

MechBook:vgm2x donluca$ make
gcc -MMD -c vgm2x.c -o vgm2x.o -Wall -ggdb -I/usr/local/include
vgm2x.c:54:15: error: use of undeclared identifier 'PATH_MAX'
                        char rpath[PATH_MAX]; // FIXME: maybe allocate n...
                                   ^
vgm2x.c:141:14: error: use of undeclared identifier 'PATH_MAX'
        char fmfile[PATH_MAX];
                    ^
vgm2x.c:288:22: error: use of undeclared identifier 'PATH_MAX'
                char writable_path[PATH_MAX];
                                   ^
vgm2x.c:304:56: warning: format specifies type 'unsigned long' but the argument
      has type 'zip_uint64_t' (aka 'unsigned long long') [-Wformat]
  ...fprintf(stderr, "Could not allocate %lu bytes\n", st.size);
                                         ~~~           ^~~~~~~
                                         %llu
vgm2x.c:314:61: warning: format specifies type 'unsigned long' but the argument
      has type 'zip_uint64_t' (aka 'unsigned long long') [-Wformat]
  ...fprintf(stderr, "Could not read %lu bytes from zip\n", st.size);
                                     ~~~                    ^~~~~~~
                                     %llu
vgm2x.c:329:15: error: use of undeclared identifier 'PATH_MAX'
                                char base[PATH_MAX];
                                          ^
vgm2x.c:353:13: error: use of undeclared identifier 'PATH_MAX'
                char base[PATH_MAX];
                          ^
2 warnings and 5 errors generated.

PATH_MAX on macOS is 1024 bytes as per

MechBook:vgm2x donluca$ grep PATH_MAX /usr/include/sys/syslimits.h*
#define	PATH_MAX		 1024	/* max bytes in pathname */

After defining PATH_MAX inside vgm2x.c the program compiles, but when ran it crashes with the following error:

MechBook:vgm2x donluca$ ./vgm2x ~/Downloads/26\ -\ Emerald\ Hill\ \(2P\).vgz -m OPM
vgm2x(52766,0x7fffa4f70380) malloc: *** error for object 0x7ffee155af00: pointer being realloc'd was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6

Tested on macOS High Sierra 10.13.6

@donluca donluca changed the title vgm2x fails to compile due to missing PATH_MAX and crashes when defined manually vgm2x fails to compile on macOS due to missing PATH_MAX and crashes when defined manually Oct 20, 2024
@donluca
Copy link
Author

donluca commented Oct 22, 2024

This is the commit that initially broke vgm2x: 366582d4b36c65b6ac5ed11c1f8aee5d6deec128

After this, it only produced a MIDI file and an INS file, even when told to produce an OPM.

This is the commit that caused the crash: 2a08863cf3d31e81eb5e33b751776c170c4d6d36

@vampirefrog
Copy link
Owner

Just needed an include fix, but now the build is failing for other reasons

#ifdef __APPLE__
#include <sys/syslimits.h>
#endif

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

2 participants