-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Segfault in binary created by zig cc related to pthread_cond_wait (musl x86_64) #7095
Comments
The most common problem with musl is that the default thread size is too small. |
I've been struggling to produce a static binary - thing is alsa & libsoundio are dynamicaly linked by default on Alpine. Also another piece for debugging info, binary produced with clang also works fine: clang -lsoundio sio_sine.c -o sio_sine So really I think this comes down to some flag that's being passed to clang with Also based on your suggestion about stack size @LemonBoy, I tried going into the libsoundio code and raising the stack size via |
Try running the program under gdb: |
Thanks for the suggestion - so I've installed gdb & debug symbols and I'm finding I think this has something to do with the way zig is interacting with alsa's shared library. I would think it's a bug with alsa, but the fact that things are working in gcc/clang with the same code and same shared library convince me that this is a zig bug. GDB trace for sio_sine.c from libsoundio:
Also I have discovered a segfault with alsa' PCM test program too (https://www.alsa-project.org/alsa-doc/alsa-lib/_2test_2pcm_8c-example.html). Same results, works in gcc & clang, doesn't work with zig cc. Here's the backtrace:
|
Commenting out And then the binary produced with |
Ok, I've managed to reproduce the problem in a alpine chroot. |
I'm currently trying to use libsoundio via zig and am experiencing problems with running libsoundio's
soundio_flush_events
function (via alsa driver). The test code I'm using is sio_sine.c from libsoundio's examples:https://github.com/andrewrk/libsoundio/blob/master/example/sio_sine.c
Example, compiling with gcc, things work normally:
However compiling with zig cc, I get a segmentation fault:
The root cause / the line that trips it up is
soundio_flush_events
and under the hood, the line that trips that up has to do withpthread_cond_wait
: https://github.com/andrewrk/libsoundio/blob/master/src/os.c#L548I'm on Alpine Linux / musl and have successfully used the same code with glibc, so I think this is a musl-specific issue. Zig code similar to the C example produces similar results, works in glibc zig, but not in musl zig.
The text was updated successfully, but these errors were encountered: