When you write a string constant and forget to escape a "
somewhere in the middle, say:
"Hello, "2" World!\n"
Then roc crashes when trying to run your program.
Interestingly, on the 'hello world' platform, Roc gives a warning ("too many arguments for function") before trying to run it anyway.
But on the cli-platform (for the 'interactive' examples), this warning is not shown, and Roc immediately crashes with what seems to be the same error, but without a veneer of Roc around the Rust panic.
Is this difference expected or not?
(Rust error shown in the 'interactive' examples:
thread '<unnamed>' panicked at 'index out of bounds: the len is 0 but the index is 0', compiler/mono/src/ir.rs:9149:35
Error as shown when doing the same thing in the 'hello world' example:
Application crashed with message
Erroneous compiler/mono/src/ir.rs line 4704
Shutting down
)
it’s a bug. how well we’re able to continue compiling when there’s a type error varies heavily and things go poorly when the types are more complicated, as they are in the cli platform. but in any case, we would like the compiler itself to avoid panicking.
And is the fact that warnings are shown for one platform and not for the other also a bug, or a setting I missed somewhere or something?
the first message you showed, “thread <unknown> panicked”, is the compiler itself crashing, which is definitely a bug. The second is the compiler finishing it’s job, and running, and the runtime crashing where it saw there was a type error. There’s a bug in the second one too, which is that the message regarding why it crashed could be a lot better.
well you already got a type error on compilation
we can still do better with the runtime error but I don't think that's an urgent issue
I don't think it is urgent either (but I have reported it for good measure: https://github.com/rtfeldman/roc/issues/3327 )
I was mostly confused by the difference in behaviour between running roc on the hello-world platform and the cli-platform
right, the difference as Ayaz mentioned is the complexity of types
Ah, that makes sense :blush:
yeah the "you can keep running even if there's a type error" functionality exists, but it's got a lot of bugs and is lower priority to work than several other things for the time being :big_smile:
Another fun one:
After merging trunk
into 3245-assoc-list
I get the following error when trying to run the example (cargo run -- run examples/assoc-list/main.roc
)
── FILE PROBLEM ────────────────────────────────────────────────── UNKNOWN.roc ─
I tried to read this file, but ran into a is a directory problem.
I did not have this problem earlier.
Am I doing something wrong?
I bet it's this https://github.com/rtfeldman/roc/issues/3249
We're getting somewhere :laughter_tears:
How do I run valgrind properly for this? I tried a simple valgrind cargo run -- run ./examples/assoc-list/main.roc
but this segfaulted still and exited valgrind itself immediately as well.
And is this maybe caused by some kind of build cache invalidation? I tried cargo clean
in the cli-platform
subdirectory of the example, but that still gave the same result. Is there something else to try?
:thinking: The segfault also shows up for other cli-platform examples (e.g. those in the examples/interactive
folder)
is this the application itself crashing?
or the compiler
I usually find out what the binary is that was created, then run valgrind on that directly
so valgrind ./examples/assoc-list/main
Thanks! It seems like the application itself is crashing. That might also be why in the other command, valgrind
output does not show up (there probably is an execve
or something happening once compilation finished, shedding the Valgrind
wrapper)
So I've bisected the problem and was able to trace it back to one commit related to allocating recursive tags @Folkert de Vries
https://github.com/rtfeldman/roc/issues/3344
indeed there is an execve
. That commit was supposed to fix issues, not create them ...
that address in binary is 0b111100010000000011101
, so it uses sub-byte addressing
the lowest 3 bits should be unused right?
One would assume so
Are there options I could pass to valgrind
or other commands I might run that might help to shed more light on the problem?
Last updated: Jul 06 2025 at 12:14 UTC