Stream: beginners

Topic: is it a bug or is it me?


view this post on Zulip Qqwy / Marten (Jun 25 2022 at 19:15):

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.

view this post on Zulip Qqwy / Marten (Jun 25 2022 at 19:15):

Is this difference expected or not?

view this post on Zulip Qqwy / Marten (Jun 25 2022 at 19:17):

(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

)

view this post on Zulip Ayaz Hafiz (Jun 25 2022 at 19:24):

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.

view this post on Zulip Qqwy / Marten (Jun 25 2022 at 19:26):

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?

view this post on Zulip Ayaz Hafiz (Jun 25 2022 at 19:29):

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.

view this post on Zulip Folkert de Vries (Jun 25 2022 at 19:30):

well you already got a type error on compilation

view this post on Zulip Folkert de Vries (Jun 25 2022 at 19:31):

we can still do better with the runtime error but I don't think that's an urgent issue

view this post on Zulip Qqwy / Marten (Jun 25 2022 at 19:33):

I don't think it is urgent either (but I have reported it for good measure: https://github.com/rtfeldman/roc/issues/3327 )

view this post on Zulip Qqwy / Marten (Jun 25 2022 at 19:34):

I was mostly confused by the difference in behaviour between running roc on the hello-world platform and the cli-platform

view this post on Zulip Folkert de Vries (Jun 25 2022 at 19:35):

right, the difference as Ayaz mentioned is the complexity of types

view this post on Zulip Qqwy / Marten (Jun 25 2022 at 19:35):

Ah, that makes sense :blush:

view this post on Zulip Richard Feldman (Jun 25 2022 at 20:08):

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:

view this post on Zulip Qqwy / Marten (Jun 27 2022 at 12:10):

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.

view this post on Zulip Qqwy / Marten (Jun 27 2022 at 12:11):

I did not have this problem earlier.

Am I doing something wrong?

view this post on Zulip Richard Feldman (Jun 27 2022 at 12:22):

I bet it's this https://github.com/rtfeldman/roc/issues/3249

view this post on Zulip Qqwy / Marten (Jun 27 2022 at 12:28):

image.png

We're getting somewhere :laughter_tears:

view this post on Zulip Qqwy / Marten (Jun 27 2022 at 12:36):

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.

view this post on Zulip Qqwy / Marten (Jun 27 2022 at 12:37):

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?

view this post on Zulip Qqwy / Marten (Jun 27 2022 at 12:38):

:thinking: The segfault also shows up for other cli-platform examples (e.g. those in the examples/interactive folder)

view this post on Zulip Folkert de Vries (Jun 27 2022 at 12:42):

is this the application itself crashing?

view this post on Zulip Folkert de Vries (Jun 27 2022 at 12:42):

or the compiler

view this post on Zulip Folkert de Vries (Jun 27 2022 at 12:43):

I usually find out what the binary is that was created, then run valgrind on that directly

view this post on Zulip Folkert de Vries (Jun 27 2022 at 12:44):

so valgrind ./examples/assoc-list/main

view this post on Zulip Qqwy / Marten (Jun 27 2022 at 12:52):

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)

view this post on Zulip Qqwy / Marten (Jun 27 2022 at 14:36):

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

view this post on Zulip Folkert de Vries (Jun 27 2022 at 16:55):

indeed there is an execve. That commit was supposed to fix issues, not create them ...

view this post on Zulip Folkert de Vries (Jun 27 2022 at 16:59):

that address in binary is 0b111100010000000011101, so it uses sub-byte addressing

view this post on Zulip Folkert de Vries (Jun 27 2022 at 17:00):

the lowest 3 bits should be unused right?

view this post on Zulip Qqwy / Marten (Jun 27 2022 at 17:50):

One would assume so

view this post on Zulip Qqwy / Marten (Jun 27 2022 at 17:51):

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