Segfault when invoking a function from a specific C library (using libc)

Hi all, thanks for reading.

This is on Fedora 43, Zig v0.15.2, and with the nightly too. I’m getting a segfault (Segmentation fault at address 0x0) when invoking any function defined in libopenal.so.

Weirdly, invoking functions from other libraries works just fine. Also, I’m linking with libc (.link_libc=true). I have no idea what is special about this libopenal.so, it comes from the system packages, just as the other libraries that do work.

.use_llvm=true apparently resolves the problem.

Can this be a bug in the compiler/linking phase? Looking at this forum and the issue trackers, I’ve not seen this exact problem. I have no further means to diagnose the problem.

did you try linking the openal lib dynamically to the bin in your build.zig? I think its using linkSystemLibrary(),

Yes, otherwise it would fail at linking. What I’m getting is a runtime error.

I have no idea if this would work but i had the same problem with a c dependency I fixed it by moving the variable with the hadle from global scope to main function. It seems like it wouldn’t work if the pointer was initialized at the global scope with undefined so I switched to lazy declaration inside the main itself and it seemed to work then.