I was trying to use Stdin from platform v0.6 to improve my AoC template, and stumbled upon some weird panic. Here is what I’ve been able to reduce it to:
I’ve got some input text file with 24 char + a final newline: oneline.txt
And then I’ve got the following roc file
# cat oneline.txt | roc crash.roc
app [main!] { pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.6/2BfGn4M9uWJNhDVeMghGeXNVDFijMfPsmmVeo6M4QjKX.tar.zst" }
import pf.Stdin
main! = |_args| {
#_l = [Stdin.line!()] # <- this works
#_l = List.append([], Stdin.line!()) # <- this panics
_l = [].append(Stdin.line!()) # <- this panics
Ok({})
}
When calling cat oneline.txt | roc crash.roc, I get the following panic.
❯ cat ../inputs/oneline.txt | roc crash.roc
thread 1901738 panic: Use-after-free: decref on already-freed memory
???:?:?: 0x10496be5f in ??? (crash.roc)
???:?:?: 0x1048f4a8f in ??? (crash.roc)
???:?:?: 0x1048f4dfb in ??? (crash.roc)
???:?:?: 0x1048d404b in ??? (crash.roc)
???:?:?: 0x1048ce0d3 in ??? (crash.roc)
???:?:?: 0x1049157d7 in ??? (crash.roc)
???:?:?: 0x1048d629b in ??? (crash.roc)
???:?:?: 0x1048ab05f in ??? (crash.roc)
???:?:?: 0x1048a83fb in ??? (crash.roc)
???:?:?: 0x1048a7edf in ??? (crash.roc)
???:?:?: 0x104c04eab in ??? (crash.roc)
???:?:?: 0x181ddab97 in ??? (???)
???:?:?: 0x0 in ??? (???)
I suppose this is a bug related to the platform, but I don’t know maybe it’s also related to the type checking or interpreter since there is this weird interaction with the List.append function? I’ve tried using the stdin with other functions and haven’t found another that also triggers the panic. I just found append.
So not sure where to open an issue for this one.
I'll investigate!
https://github.com/roc-lang/roc/pull/8635 should fix this
Anton has marked this topic as resolved.
Last updated: Dec 21 2025 at 12:15 UTC