Stream: bugs

Topic: Regressions (segfaults) after the latest PR (ranges)


view this post on Zulip Matthieu Pizenberg (Dec 05 2025 at 18:00):

It seems like my AoC solution for day 1 is now segfaulting after the ranges PR. Should I look into it or is it something you are aware of already?

view this post on Zulip Matthieu Pizenberg (Dec 05 2025 at 18:17):

So the regression is related to the one-liner for my print! function.

print! = |msg| msg.split_on("\n").for_each!(Stdout.line!)

Before the latest PR, this works. But after the ranges PR, I now have to write it again with a for loop to not trigger a segfault. @Richard Feldman I believe you had fixed that issue in another PR a few days back. Some of your changes in the range PR might have re-introduced some negative effect on this line.

view this post on Zulip Matthieu Pizenberg (Dec 05 2025 at 18:37):

Hum actually it’s not just that. Context matters. I’m looking into it more and trying to make another minimal reproducible example.

view this post on Zulip Matthieu Pizenberg (Dec 05 2025 at 19:06):

Ok, this is the weirdest bug I’ve ever seen. Here is my minimal example with a segfault on main (4766997).

app [main!] { pf: platform "./platform/main.roc" }

import pf.Stdout

print! : Str => {}
print! = |msg| msg.split_on("\n").for_each!(Stdout.line!)

fnA : Str -> Try(I64, _)
fnA = |_input| {
    var $x = 1
    Ok($x)
}

fnB : Str -> Try(I64, _)
fnB = |_input| {
    var $y = 2
    Ok($y)
}

run! = || {
    print!("A1: ${fnA("test")?.to_str()}")
    print!("A2: ${fnA("test")?.to_str()}")
    print!("A3: ${fnA("test")?.to_str()}")
    Ok({})
}

main! = || {
    _ignore = run!()
}

If I do any of the following things, there is NO segfault anymore.

This is truly a mystery to me how to minimize this segfault further.

view this post on Zulip Matthieu Pizenberg (Dec 05 2025 at 19:09):

 roc test/fx/segfault.roc
A1: 1
A2: 1
error: Child process /var/folders/q3/lls0f9bd6x112cdkq8bgjldr0000gn/T/roc-65931/segfault.roc killed by signal: 11
error: Child process crashed with segmentation fault (SIGSEGV)

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

This is truly a mystery to me how to minimize this segfault further.

Try getting a stacktrace with gdb: gdb --ex run --ex bt --args roc test/fx/segfault.roc that may get you some extra useful info.

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

I have my OS pretty locked down so that I can safely run codex --yolo or claude --dangerously-skip-permissions. They should be able to find the cause of the segfault in that mode but they don't always find the best fix.

view this post on Zulip Richard Feldman (Dec 05 2025 at 20:01):

I'll take a look!

view this post on Zulip Richard Feldman (Dec 06 2025 at 05:19):

https://github.com/roc-lang/roc/pull/8576 should fix this, although I'm not quite ready to land the PR yet - needs some changes, but if you try that branch it should unblock!

view this post on Zulip Matthieu Pizenberg (Dec 06 2025 at 10:53):

Indeed, it fixes the segfault for day 1 :)


Last updated: Dec 21 2025 at 12:15 UTC