Hi all, I am trying to get the new compiler set up for the Advent of Code, but I am running into a segfault. I started with the AoC snippet on the gist, and tried with the latest compiled version of git as well as the latest version of the platform, but I keep getting segfaults. Any ideas on how I can fix that?
roc --no-cache day1.roc results in:
error: Child process /home/personal/.cache/roc/e59c636351ad64c25ba81dca340f7248/temp/roc-tmp-bFsSwh08ITK6jzGnh60qSlf2SM6zBcHO/roc_run_2372458751 killed by signal: 11
error: Child process crashed with segmentation fault (SIGSEGV)
I did notice I got errors for the build tests:
~/.zig/zig build test results in
Build Summary: 54/57 steps succeeded; 1 failed; 1797/1845 tests passed; 1 skipped; 47 failed
test transitive failure
└─ tests_summary transitive failure
└─ run test fx_platform_test 0/47 passed, 47 failed
error: the following build command failed with exit code 1:
.zig-cache/o/d9d16c1099fe679e867f0f1a0b415354/build /home/personal/.zig/zig /home/personal/.zig/lib /home/personal/Documents/Dev/roc .zig-cache /home/personal/.cache/zig --seed 0x4a32e7f3 -Z7d6ff281091d6793 test
By "latest compiled version of git" do you mean you compiled it from the git repo, or you used a published pre-compiled one?
With that I mean compiled from the git repo. I tried the recommended nightly as well but neither seemed to work (could be that I used the wrong combination of compiler + platform version)
Currently if you want to make sure you have the latest version from the main branch. The simplest way is to clone fresh, or if you cloned already, you pull main again, then git clean -fdx to remove everything not supposed to be in the folder. Then zig build rebuild-builtins && zig build and if that’s ok, zig build test. (That’s my paranoid way of making sure I’m good, but maybe some steps aren’t needed ^^)
Zig compiler must be version 0.15.2 I believe.
I just cloned, but I followed your steps (for your sanity as well as mine :)), but I still got the same issue.
Also checked the zig version, it is indeed 15.2
I just set up the roc repo and zig
I pulled latest main (b578eea38f443c1de8e4f3b3f606b17214014e70) and followed the same instructions above and the tests pass. NixOS x86, using the dev shell of./src/flake.nix.
What OS/arch are you on?
Fedora 42, Kernel 6.17.9
Any other useful info I can provide?
Could you share what zig build test --summary all shows please?
Just reconfirmed the git commit hash
We haven't tested on fedora yet asfaik
There you go
I wonder what tier support fedora has with Zig, that fx platform is using zig std lib calls so it's surprising.
I am using this exact command as I haven't loaded the path if that's relevant ~/.zig/zig build test --summary all
What does zig build roc give you?
Roc cache not found (nothing to clear), with zig_out/bin containing the roc binary
It seems those test are all failing at the same point ensureRocBinary
Ohk, so roc builds... can you run ./zig-out/bin/roc version
/home/personal/.roc/latest/roc: /lib64/libtinfo.so.6: no version information available (required by /ho
me/personal/.roc/latest/roc)
roc nightly pre-release, built from commit d73ea109 on Tue 09 Sep 2025 09:02:08 AM UTC
The no version information available error was also present in the old compiler, but everything still worked
wait, that was the one in path, not the compiled one
Roc compiler version debug-b578eea3
const roc_binary_path = if (builtin.os.tag == .windows) ".\\zig-out\\bin\\roc.exe" else "./zig-out/bin/roc"
Maybe this goes wrong because I am using ~/.zig/zig?
yeah that'd probably be it
possibly*
I have gotten the path working (Nushell shenanigans, now falling back to bash) and now the tests succeed
I was racing to get a Fedora 42 VM running - dropping that! :P
Okay, so I put the new roc binary in my path and ran the example as on the Gist, but still no dice:
roc version: Roc compiler version debug-b578eea3
roc --no-cache day1.roc:
error: Child process /home/personal/.cache/roc/e59c636351ad64c25ba81dca340f7248/temp/roc-tmp-wCL3AsLNHM1fkMNPe8Wf3IMsSYtHSzdg/roc_run_2372458751 killed by signal: 11
error: Child process crashed with segmentation fault (SIGSEGV)
Does it work if you put the Roc code into test/fx/app.roc of the Roc compiler project and run that from the project root?
If no, could you paste the exact Roc code you're running?
It could be that the URL from the snippet is an older release of the platform with a known bug it it. I haven't been taking down older links for the zig template platform
If the zig tests are passing the most logical thing I can think of is the platform
If your on the latest release of the platfrom and it still fails... I'd be interested to know if zig build succeeds, and then if you can run an fx test app manually.. like .\zig-out\bin\roc test\fx\app.roc etc
I'm on it, was still faffing about with getting it all running
I compiled roc and ran ./zig-out/bin/roc test/fx/app.roc from the root of the roc compiler repo, still the same error
Can you paste your full Roc source?
Yes, forgot about that:
app [main!] { pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.3/98T93wthPgoBRLYtPTT4RBBsQunrfDG94gihPf1zYYmE.tar.zst" }
import pf.Stdout
main! = |_args| {
Stdout.line!("Hello, World!")
Ok({})
}
zig build test --summary all returns
Using that source I'm segfaulting too:
./zig-out/bin/roc test/fx/app.roc
error: Child process /home/niclas/.cache/roc/e59c636351ad64c25ba81dca340f7248/temp/roc-tmp-peyESAxE4KSKWkmYBrByTDx2QmyibQwP/roc_run_792223834 killed by signal: 11
error: Child process crashed with segmentation fault (SIGSEGV)
Can run the built-in example (with the built-in platform) fine:
./zig-out/bin/roc test/fx/app.roc
Hello from stdout!
Line 1 to stdout
Line 2 to stderr
Line 3 to stdout
Error from stderr!
And the segfaulting example is using the latest platform version and compiler version is latest (b578eea38f443c1de8e4f3b3f606b17214014e70).
All platform versions seem to give the segfault
Nice! That's one step closer
Can confirm that the built-in example runs fine:
Hello from stdout!
Line 1 to stdout
Line 2 to stderr
Line 3 to stdout
Error from stderr!
Some more interesting findings (all running ./zig-out/bin/roc test/fx/app.roc) :
Just importing the platform:
app [main!] { pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.3/98T93wthPgoBRLYtPTT4RBBsQunrfDG94gihPf1zYYmE.tar.zst" }
import pf.Stdout
import pf.Stderr
str : Str -> Str
str = |s| s
main! = || {
Stdout.line!(str("Hello from stdout!"))
Stdout.line!(str("Line 1 to stdout"))
Stderr.line!(str("Line 2 to stderr"))
Stdout.line!(str("Line 3 to stdout"))
Stderr.line!(str("Error from stderr!"))
}
gives
-- TYPE MISMATCH ---------------------------------
This expression is used in an unexpected way:
┌─ test/fx/app.roc:9:1
│
9 │ main! = || {
│ ^^^^^
It has the type:
({}) => { }
But the type annotation says it should have the type:
List(Str) => Try({ }, [Exit(I32)])
Found 1 error(s) and 0 warning(s) for test/fx/app.roc.
Adding |_args and Ok({})
app [main!] { pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.3/98T93wthPgoBRLYtPTT4RBBsQunrfDG94gihPf1zYYmE.tar.zst" }
import pf.Stdout
import pf.Stderr
str : Str -> Str
str = |s| s
main! = |_args| {
Stdout.line!(str("Hello from stdout!"))
Stdout.line!(str("Line 1 to stdout"))
Stderr.line!(str("Line 2 to stderr"))
Stdout.line!(str("Line 3 to stdout"))
Stderr.line!(str("Error from stderr!"))
Ok({})
}
gives
thread 68341 panic: incorrect alignment
/home/personal/Documents/Dev/roc/src/eval/StackValue.zig:894:39: 0x43b436 in storeListElementCount (mod.zig)
const ptr = @as([*]usize, @ptrCast(@alignCast(source))) - 2;
^
/home/personal/Documents/Dev/roc/src/eval/StackValue.zig:190:30: 0x3c6cad in copyToPtr (mod.zig)
storeListElementCount(dest_list, elements_refcounted);
^
/home/personal/Documents/Dev/roc/src/eval/interpreter.zig:782:30: 0x3cab0b in pushCopy (mod.zig)
try src.copyToPtr(&self.runtime_layout_store, ptr.?, roc_ops);
^
/home/personal/Documents/Dev/roc/src/eval/interpreter.zig:6434:49: 0x3d3b7d in patternMatchesBind (mod.zig)
const copied = try self.pushCopy(value, roc_ops);
^
/home/personal/Documents/Dev/roc/src/eval/interpreter.zig:589:64: 0x3de83e in evaluateExpression (mod.zig)
const matched = try self.patternMatchesBind(params[j], arg_value, param_rt_vars[j], roc_ops, &temp_binds, @enumFromInt(0));
^
/home/personal/Documents/Dev/roc/src/interpreter_shim/main.zig:174:39: 0x3b9b77 in evaluateFromSharedMemory (main.zig)
try interpreter.evaluateExpression(expr_idx, ret_ptr, roc_ops, arg_ptr);
^
/home/personal/Documents/Dev/roc/src/interpreter_shim/main.zig:71:29: 0x3b8f0e in roc_entrypoint (main.zig)
evaluateFromSharedMemory(entry_idx, ops, ret_ptr, arg_ptr) catch |err| {
^
/home/personal/Documents/Dev/roc/test/fx/platform/host.zig:300:14: 0x282543 in platform_main (host.zig)
roc__main(&roc_ops, @as(*anyopaque, @ptrCast(&ret)), @as(*anyopaque, @ptrCast(&args)));
^
/home/personal/Documents/Dev/roc/test/fx/platform/host.zig:168:18: 0x282668 in main (host.zig)
platform_main() catch |err| {
^
src/env/__libc_start_main.c:95:2: 0xaca54c in libc_start_main_stage2 (src/env/__libc_start_main.c)
Unwind error at address `exe:0xaca54c` (error.MissingFDE), trace may be incomplete
???:?:?: 0x0 in ??? (???)
error: Child process /home/personal/.cache/roc/e59c636351ad64c25ba81dca340f7248/temp/roc-tmp-QrCVuZwQCTugoE4UXr9kfu6No9KsEwgj/roc_run_792223834 killed by signal: 6
error: Child process aborted (SIGABRT)
Try deleting the Roc cache (rm -rf ~/.cache/roc or such) and re-running. You'll probably be back at the segfault.
Yup, that's right
This is probably a problem for a Wizard. Perhaps use the built-in platform for now or play a delightful session of Diablo II and I'm sure it'll be in order when you return!
More of a Cities Skylines guy myself, so I guess I'll get to building some suburbs :laughing:
There's a guy who does Cities Skylines videos in YoutTube that loves drinking tea. I think Biffa is his name... that you? :joy:
No that's a different guy, I just also happen to drink tea and enjoy Cities Skylines :joy:
If anyone wants to/can help me further and needs some more info, just ping me, I'll be keeping an eye on this channel
I’m with you, @TeaDrinkingProgrammer . I was excited to try the new Roc compiler for AoC, but I’m running into the same segfault. I’m on the latest MacOS Silicon binary.
I'll check this out
This works for me on the latest roc commit 04bb3f9270bda4306828aa2c0194d10755ecdf74 (built from source), on apple silicon. Source code:
app [main!] { pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.3/98T93wthPgoBRLYtPTT4RBBsQunrfDG94gihPf1zYYmE.tar.zst" }
import pf.Stdout
main! = |_args| {
Stdout.line!("Hello, World!")
Ok({})
}
Can confirm on macOS Apple Silicon. Sadly not on NixOS x86:
./zig-out/bin/roc appc.roc
error: Child process /home/niclas/.cache/roc/5931167c7313ef73dbb36e68e48b39cf/temp/roc-tmp-pkhvoyUrxhdo7z21VPuLALspQGB5rbo2/roc_run_1644006530 killed by signal: 11
error: Child process crashed with segmentation fault (SIGSEGV)
Same source and Roc built from source (04bb3f9270bda4306828aa2c0194d10755ecdf74). git clean -fdx, rm -rf ~/.cache/roc, and zig build test passing before testing.
Any commands/logs I can supply to make it easier for you to find the cause?
No, it's fine, I will probably be able to reproduce on linux too
It does not happen when building roc-platform-template-zig from source, make sure to use roc --no-cache myfile.roc if you just switched out the platform line though.
Looks like it was a linking issue, I will automate releases and add more testing too.
I know what's wrong, fix is underway
Thanks for the update, works for me! I hadn’t seen the latest version with the GitHub’s odd sorting.
Is there a new version of something already? I can't find anything
Never mind, found it. Like it says in the nightlies channel, the 5 december release is shown as being 5 days old.
Just out of curiosity, what was the problem in the end?
the 5 december release is shown as being 5 days old
Weird, it's shown as 10 hours old for me
TeaDrinkingProgrammer said:
Just out of curiosity, what was the problem in the end?
.o files were not included in the .tar.zst, a specific .o file is necessary for (musl) linux.
Fixed :)
This is the header for the latest release:
app [main!] { pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.4/6XA8JLWhmG1FSgb8GxPjBs9cGrtRqopohR3KAHYo722z.tar.zst" }
Last updated: Dec 21 2025 at 12:15 UTC