For one of my program, the compiler produces perfectly working code with -O ReleaseFast and -O ReleaseSafe, but produces code that SIGSEGV when using either no option or -O Debug (!)
When compiled with Debug and started with lldb, the error is quite amazing:
stop reason = signal SIGSEGV: address not mapped to object (fault address: 0x7ffffeffeeb0)
The address seems to be the start of a perfectly ordinary function.
Anyone has an idea?
There is nothing special in the code. It is the call of a function. There is a debug print just before the call, a debug print just after the start of the function, the first appears, the second never appears. I was wondering if there was a difference in backend generating code or in optimizations in 15.1 (the code was OK in 14.1)
In 0.15 Zig now uses the self-hosted x64 backend by default. Given that this is still fairly new there may be some problems with it. To work around it you may be able to use the flag -fllvm to tell it to use the old llvm backend.
If that is the problem then it would be helpful if you could post a minimal executable that breaks, and create a bug report on github so that the compiler developers can take a look at it.
Genrally in order to help you it would be good to have a full program, otherwise we can only guess what really went wrong, e.g. here the bug may also lie in the code that constructs stderr or in a completely separate part of the program. And it’s also difficult to try your code if I have to first reimplement half of it myself, compared to just copy-pasting a working program.
Luckily for you the issue was just fixed a few days ago and if you try the latest zig-0.16-dev release it should work. If you can’t afford to switch then I guess you can just stick to the llvm backend until 0.16.0 releases.