Stream: beginners

Topic: New Compiler: segfault running gist example


view this post on Zulip TeaDrinkingProgrammer (Dec 03 2025 at 19:18):

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

view this post on Zulip Matthieu Pizenberg (Dec 03 2025 at 19:21):

By "latest compiled version of git" do you mean you compiled it from the git repo, or you used a published pre-compiled one?

view this post on Zulip TeaDrinkingProgrammer (Dec 03 2025 at 19:23):

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)

view this post on Zulip Matthieu Pizenberg (Dec 03 2025 at 19:24):

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 ^^)

view this post on Zulip Matthieu Pizenberg (Dec 03 2025 at 19:25):

Zig compiler must be version 0.15.2 I believe.

view this post on Zulip TeaDrinkingProgrammer (Dec 03 2025 at 19:27):

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

view this post on Zulip TeaDrinkingProgrammer (Dec 03 2025 at 19:28):

I just set up the roc repo and zig

view this post on Zulip Niclas Ahden (Dec 03 2025 at 19:29):

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?

view this post on Zulip TeaDrinkingProgrammer (Dec 03 2025 at 19:30):

Fedora 42, Kernel 6.17.9

view this post on Zulip TeaDrinkingProgrammer (Dec 03 2025 at 19:31):

Any other useful info I can provide?

view this post on Zulip Luke Boswell (Dec 03 2025 at 19:32):

Could you share what zig build test --summary all shows please?

view this post on Zulip TeaDrinkingProgrammer (Dec 03 2025 at 19:32):

Just reconfirmed the git commit hash

view this post on Zulip Luke Boswell (Dec 03 2025 at 19:32):

We haven't tested on fedora yet asfaik

view this post on Zulip TeaDrinkingProgrammer (Dec 03 2025 at 19:34):

PastedText.txt

view this post on Zulip TeaDrinkingProgrammer (Dec 03 2025 at 19:34):

There you go

view this post on Zulip Luke Boswell (Dec 03 2025 at 19:34):

I wonder what tier support fedora has with Zig, that fx platform is using zig std lib calls so it's surprising.

view this post on Zulip TeaDrinkingProgrammer (Dec 03 2025 at 19:34):

I am using this exact command as I haven't loaded the path if that's relevant ~/.zig/zig build test --summary all

view this post on Zulip Luke Boswell (Dec 03 2025 at 19:38):

What does zig build roc give you?

view this post on Zulip TeaDrinkingProgrammer (Dec 03 2025 at 19:41):

Roc cache not found (nothing to clear), with zig_out/bin containing the roc binary

view this post on Zulip Luke Boswell (Dec 03 2025 at 19:41):

It seems those test are all failing at the same point ensureRocBinary

view this post on Zulip Luke Boswell (Dec 03 2025 at 19:42):

Ohk, so roc builds... can you run ./zig-out/bin/roc version

view this post on Zulip TeaDrinkingProgrammer (Dec 03 2025 at 19:43):

/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

view this post on Zulip TeaDrinkingProgrammer (Dec 03 2025 at 19:44):

wait, that was the one in path, not the compiled one

view this post on Zulip TeaDrinkingProgrammer (Dec 03 2025 at 19:44):

Roc compiler version debug-b578eea3

view this post on Zulip TeaDrinkingProgrammer (Dec 03 2025 at 19:45):

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?

view this post on Zulip Luke Boswell (Dec 03 2025 at 19:46):

yeah that'd probably be it

view this post on Zulip Luke Boswell (Dec 03 2025 at 19:47):

possibly*

view this post on Zulip TeaDrinkingProgrammer (Dec 03 2025 at 19:50):

I have gotten the path working (Nushell shenanigans, now falling back to bash) and now the tests succeed

view this post on Zulip Niclas Ahden (Dec 03 2025 at 19:52):

I was racing to get a Fedora 42 VM running - dropping that! :P

view this post on Zulip TeaDrinkingProgrammer (Dec 03 2025 at 19:54):

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)

view this post on Zulip Niclas Ahden (Dec 03 2025 at 19:55):

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?

view this post on Zulip Niclas Ahden (Dec 03 2025 at 19:56):

If no, could you paste the exact Roc code you're running?

view this post on Zulip Luke Boswell (Dec 03 2025 at 19:58):

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

view this post on Zulip Luke Boswell (Dec 03 2025 at 19:59):

If the zig tests are passing the most logical thing I can think of is the platform

view this post on Zulip Luke Boswell (Dec 03 2025 at 20:01):

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

view this post on Zulip TeaDrinkingProgrammer (Dec 03 2025 at 20:06):

I'm on it, was still faffing about with getting it all running

view this post on Zulip TeaDrinkingProgrammer (Dec 03 2025 at 20:07):

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

view this post on Zulip Niclas Ahden (Dec 03 2025 at 20:08):

Can you paste your full Roc source?

view this post on Zulip TeaDrinkingProgrammer (Dec 03 2025 at 20:08):

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({})
}

view this post on Zulip TeaDrinkingProgrammer (Dec 03 2025 at 20:09):

zig build test --summary all returns

PastedText.txt

view this post on Zulip Niclas Ahden (Dec 03 2025 at 20:11):

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).

view this post on Zulip TeaDrinkingProgrammer (Dec 03 2025 at 20:11):

All platform versions seem to give the segfault

view this post on Zulip TeaDrinkingProgrammer (Dec 03 2025 at 20:12):

Nice! That's one step closer

view this post on Zulip TeaDrinkingProgrammer (Dec 03 2025 at 20:13):

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!

view this post on Zulip TeaDrinkingProgrammer (Dec 03 2025 at 20:18):

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)

view this post on Zulip Niclas Ahden (Dec 03 2025 at 20:22):

Try deleting the Roc cache (rm -rf ~/.cache/roc or such) and re-running. You'll probably be back at the segfault.

view this post on Zulip TeaDrinkingProgrammer (Dec 03 2025 at 20:23):

Yup, that's right

view this post on Zulip Niclas Ahden (Dec 03 2025 at 20:26):

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!

view this post on Zulip TeaDrinkingProgrammer (Dec 03 2025 at 20:30):

More of a Cities Skylines guy myself, so I guess I'll get to building some suburbs :laughing:

view this post on Zulip Luke Boswell (Dec 03 2025 at 20:38):

There's a guy who does Cities Skylines videos in YoutTube that loves drinking tea. I think Biffa is his name... that you? :joy:

view this post on Zulip TeaDrinkingProgrammer (Dec 03 2025 at 20:39):

No that's a different guy, I just also happen to drink tea and enjoy Cities Skylines :joy:

view this post on Zulip TeaDrinkingProgrammer (Dec 03 2025 at 21:25):

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

view this post on Zulip Ghislain (Dec 03 2025 at 23:50):

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.

view this post on Zulip Anton (Dec 05 2025 at 11:29):

I'll check this out

view this post on Zulip Anton (Dec 05 2025 at 11:50):

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({})
}

view this post on Zulip Niclas Ahden (Dec 05 2025 at 12:02):

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.

view this post on Zulip TeaDrinkingProgrammer (Dec 05 2025 at 12:43):

Any commands/logs I can supply to make it easier for you to find the cause?

view this post on Zulip Anton (Dec 05 2025 at 13:11):

No, it's fine, I will probably be able to reproduce on linux too

view this post on Zulip Anton (Dec 05 2025 at 13:53):

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.

view this post on Zulip Anton (Dec 05 2025 at 13:57):

Looks like it was a linking issue, I will automate releases and add more testing too.

view this post on Zulip Anton (Dec 05 2025 at 17:04):

I know what's wrong, fix is underway

view this post on Zulip Ghislain (Dec 05 2025 at 18:42):

Thanks for the update, works for me! I hadn’t seen the latest version with the GitHub’s odd sorting.

view this post on Zulip TeaDrinkingProgrammer (Dec 05 2025 at 19:18):

Is there a new version of something already? I can't find anything

view this post on Zulip TeaDrinkingProgrammer (Dec 05 2025 at 19:20):

Never mind, found it. Like it says in the nightlies channel, the 5 december release is shown as being 5 days old.

view this post on Zulip TeaDrinkingProgrammer (Dec 05 2025 at 19:26):

Just out of curiosity, what was the problem in the end?

view this post on Zulip Anton (Dec 05 2025 at 19:46):

the 5 december release is shown as being 5 days old

Weird, it's shown as 10 hours old for me

view this post on Zulip Anton (Dec 05 2025 at 19:47):

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.

view this post on Zulip Anton (Dec 05 2025 at 19:59):

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