Hi
I am trying to write a zig-platform that uses SDL. I am not able, to get it build for the surgical or the legacy linker.
When I build it for the surgical linker, I first create a libapp.so
from an example app and then compile the zig-code with it. I get a dynhost
-executable. If I start this executalbe it works. It starts the program with the compiled roc code.
But when I try to to start it with roc run
, I get the error:
🔨 Rebuilding platform...
Segmentation fault at address 0x78c5b62c8098
/home/ossi/zig/0.13.0/files/lib/compiler_rt/memcpy.zig:14:9: 0x5a929e0bb258 in memcpy (compiler_rt)
if (len != 0) {
^
Unwind error at address `:0x5a929e0bb258` (error.InvalidCFA), trace may be incomplete
I have no idea, what is going on or how to fix it. Does anybody of you have seen an error like this?
The code is here: https://github.com/ostcar/roc-turtle
To build an run the dynhost
run:
zig build preprocess
./platform/dynhost
We've been hitting more issues in general with zig 0.13. noticed that on the branch upgrading llvm and zig. No idea why though
So issues that go away in release fast due to skipping extra checks. Others that stick.
Not havimg a trace makes that really hard to guess. Can you form a debug build of the zig host and see if you get a stack trace.
The zig version is not the issue. I get the same behavior , when I downgrade the code for zig 0.11.0 and compile it with that zig version.
Here is a branch, that for zig 0.11.0: https://github.com/ostcar/roc-turtle/tree/zig-11
zig version
0.11.0
zig build preprocess
./platform/dynhost # this works
roc build examples/roc/main.roc # this works
./examples/roc/main
Segmentation fault at address 0x74800dd69098
/home/ossi/zig/0.11.0/files/lib/compiler_rt/memcpy.zig:14:9: 0x5918d42d06d8 in memcpy (compiler_rt)
if (len != 0) {
^
Unwind error at address `:0x5918d42d06d8` (error.InvalidCFA), trace may be incomplete
I don't know how to create a better stack trace. I build zig from source and I get the same output:
../zig/build-master/stage3/bin/zig version
0.14.0-dev.839+a931bfada
../zig/build-master/stage3/bin/zig build preprocess
roc run examples/roc/main.roc
🔨 Rebuilding platform...
Segmentation fault at address 0x7748756ce098
/home/ossi/src/zig/build-master/stage3/lib/zig/compiler_rt/memcpy.zig:14:9: 0x5d23a1a51f48 in memcpy (compiler_rt)
if (len != 0) {
^
Unwind error at address `:0x5d23a1a51f48` (error.InvalidCFA), trace may be incomplete
I think I found a solution.
When I use zig 0.11.0 and set dynhost.disable_stack_probing = true;
(dynhost is the compiling step), it works.
They removed this option somewhere between 0.11.0 and 0.13.0. I have to check if there is an alternative.
Ok. Found it. They changed the option in this commit. The new way to disable stack probing is with dynhost.root_module.stack_check = false;
This fixed a number of failing tests on the llvm upgrade branch. :smiley:
Happy to help :heart_kiss:
Also gave me a good idea for another potential issue I'm looking into
Last updated: Jul 05 2025 at 12:14 UTC