Stream: bugs

Topic: Seeing panic with SIGSEGV with absolutely minimal program


view this post on Zulip Anthony Bullard (Dec 26 2025 at 15:26):

Using @Luke Boswell 's roc-platform-template-zig:

app [main!] {
    pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.6/2BfGn4M9uWJNhDVeMghGeXNVDFijMfPsmmVeo6M4QjKX.tar.zst"
}

main! = |_args| {
    Err(Exit(1)) # You can put Ok({}) as well, and it fails
}

I've tried about 10 different programs adding and removing certain language features, but they all fail. This is _likely_ a platform issue - maybe specific to mac. I can build very small programs successfully with the test/fx platform, but it is limited (no cli args for example)

view this post on Zulip Anthony Bullard (Dec 26 2025 at 15:26):

Error output:

❯ ../roc/zig-out/bin/roc examples/CommandLineArgs/main.roc || echo $?
thread 206406346 panic: reached unreachable code
???:?:?: 0x1024c40eb in ??? (main.roc)
???:?:?: 0x1024d288f in ??? (main.roc)
???:?:?: 0x1024bd9c3 in ??? (main.roc)
???:?:?: 0x1024ba703 in ??? (main.roc)
???:?:?: 0x1024ba1a7 in ??? (main.roc)
???:?:?: 0x10285f383 in ??? (main.roc)
???:?:?: 0x10241fec7 in ??? (main.roc)
???:?:?: 0x18f5b6b97 in ??? (???)
???:?:?: 0x0 in ??? (???)
134

view this post on Zulip Anthony Bullard (Dec 26 2025 at 15:27):

Obviously the stack trace is less than helpful

view this post on Zulip Anthony Bullard (Dec 26 2025 at 15:34):

Interestingly enough, this runs successfully with a locally built version of the platform

view this post on Zulip Anton (Dec 26 2025 at 15:34):

Hmm strange, are you on intel mac?

view this post on Zulip Anthony Bullard (Dec 26 2025 at 15:36):

No M1

view this post on Zulip Anthony Bullard (Dec 26 2025 at 15:37):

Here's what's stranger

view this post on Zulip Anthony Bullard (Dec 26 2025 at 15:39):

I actually get the same error with the local built platform when called from where I was.

# Root of roc-examples repo (roc is a sibling dir)
../roc/zig-out/bin/roc examples/CommandLineArgs/main.roc

with this output:

❯ ../roc/zig-out/bin/roc examples/CommandLineArgs/main.roc
thread 206427882 panic: reached unreachable code
???:?:?: 0x102ba00eb in ??? (main.roc)
???:?:?: 0x102bae88f in ??? (main.roc)
???:?:?: 0x102b999c3 in ??? (main.roc)
???:?:?: 0x102b96703 in ??? (main.roc)
???:?:?: 0x102b961a7 in ??? (main.roc)
???:?:?: 0x102f3b383 in ??? (main.roc)
???:?:?: 0x102afbec7 in ??? (main.roc)
???:?:?: 0x18f5b6b97 in ??? (???)
???:?:?: 0x0 in ??? (???)

But when I cd out one level to the parent of roc,roc-example, and roc-platform-template-zig:

./roc/zig-out/bin/roc roc-examples/examples/CommandLineArgs/main.roc

I get the following output (and success):

debug: [HOST] Building args...
debug: [ALLOC] ptr=0x103160008 size=40 align=8
debug: [ALLOC] ptr=0x103180008 size=117 align=8
debug: [HOST] args_list ptr=0x103160018 len=1
debug: [HOST] Calling roc__main_for_host...
debug: [ALLOC] ptr=0x103160048 size=45 align=8
dbg: "???"
debug: [ALLOC] ptr=0x103160088 size=45 align=8
debug: [ALLOC] ptr=0x103340008 size=256 align=8
debug: [DEALLOC] ptr=0x103340008 align=8
debug: [ALLOC] ptr=0x103180088 size=64 align=8
Part 1 (demo): 3
debug: [DEALLOC] ptr=0x103180088 align=8
debug: [ALLOC] ptr=0x103360008 size=256 align=8
debug: [DEALLOC] ptr=0x103360008 align=8
debug: [ALLOC] ptr=0x103180108 size=64 align=8
Part 1: 3
debug: [DEALLOC] ptr=0x103180108 align=8
debug: [ALLOC] ptr=0x103380008 size=256 align=8
debug: [DEALLOC] ptr=0x103380008 align=8
debug: [ALLOC] ptr=0x103180188 size=64 align=8
Part 2 (demo): 0
debug: [DEALLOC] ptr=0x103180188 align=8
debug: [ALLOC] ptr=0x1033a0008 size=256 align=8
debug: [DEALLOC] ptr=0x1033a0008 align=8
debug: [ALLOC] ptr=0x103180208 size=64 align=8
Part 2: 0
debug: [DEALLOC] ptr=0x103180208 align=8
debug: [DEALLOC] ptr=0x103160088 align=8
debug: [DEALLOC] ptr=0x103160048 align=8
debug: [DEALLOC] ptr=0x103180008 align=8
debug: [DEALLOC] ptr=0x103160008 align=8
debug: [HOST] Returned from roc, exit_code=0

BUT, when I call it from the roc-platform-template-zig directory, I get the following output:

❯ ../roc/zig-out/bin/roc ../roc-examples/examples/CommandLineArgs/main.roc
dbg: "???"
Part 1 (demo): 3
Part 1: 3
Part 2 (demo): 0
Part 2: 0

All using the same code / object files / binary

view this post on Zulip Anton (Dec 26 2025 at 15:42):

This works for me with latest main roc on m2 cpu:

app [main!] {
    pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.6/2BfGn4M9uWJNhDVeMghGeXNVDFijMfPsmmVeo6M4QjKX.tar.zst"
}

main! = |_args| {
    Err(Exit(1)) # You can put Ok({}) as well, and it fails
}

I recommend doing a git clean -fdx to remove old platform files.

view this post on Zulip Anthony Bullard (Dec 26 2025 at 15:43):

Screen Recording 2025-12-26 at 9.41.29 AM.mov
Here's a video

view this post on Zulip Anthony Bullard (Dec 26 2025 at 15:44):

Same behavior after git clean -xfd AND rm -rf ~/.cache/roc

view this post on Zulip Anthony Bullard (Dec 26 2025 at 15:45):

This is obviously with a program with some behavior now

view this post on Zulip Anton (Dec 26 2025 at 15:45):

Hmm, how about with roc main.roc --no-cache?

view this post on Zulip Anthony Bullard (Dec 26 2025 at 15:45):

Also, Hi Anton, I hope you have ben well

view this post on Zulip Anton (Dec 26 2025 at 15:46):

Hi Anthony, I have been doing well :) How about you?

view this post on Zulip Anthony Bullard (Dec 26 2025 at 15:46):

Wow. Adding --no-cache (thanks for that) makes them all behave the same...

view this post on Zulip Anton (Dec 26 2025 at 15:47):

Anthony Bullard said:

This is obviously with a program with some behavior now

I don't know what that means :p

view this post on Zulip Anthony Bullard (Dec 26 2025 at 15:47):

Where is this magical cache

view this post on Zulip Anthony Bullard (Dec 26 2025 at 15:47):

Anton said:

Anthony Bullard said:

This is obviously with a program with some behavior now

I don't know what that means :p

Sorry, I meant that I put some actual code back into this file once I had it working with the locally built platform

view this post on Zulip Anthony Bullard (Dec 26 2025 at 15:48):

Are we rebuilding ./zig-out/lib/libroc_shim.a?

view this post on Zulip Anton (Dec 26 2025 at 15:49):

I'm not sure, let me check

view this post on Zulip Anton (Dec 26 2025 at 15:53):

Anthony Bullard said:

Where is this magical cache

I think it's ~/Library/Caches/roc/

view this post on Zulip Anthony Bullard (Dec 26 2025 at 15:54):

Yep, just found it too

view this post on Zulip Anthony Bullard (Dec 26 2025 at 15:55):

So interesting. I don't still understand why calling the same code with the same binary from different locations would differ

view this post on Zulip Anthony Bullard (Dec 26 2025 at 15:55):

But, I'm unblocked so thank you my good sir. I will now use --no-cache first before I raise an issue

view this post on Zulip nandi (Dec 26 2025 at 17:50):

I learned this the hard way as well lol


Last updated: Jan 12 2026 at 12:19 UTC