Stream: beginners

Topic: display overflow stacktrace


view this post on Zulip Kevin Gillette (Dec 08 2022 at 09:49):

How might I get Roc to display a stack trace when a crash/panic or overflow occurs?

I see

Roc crashed with:

        integer subtraction overflowed!

Here is the call stack that led to the crash:


Optimizations can make this list inaccurate! If it looks wrong, try running without `--optimize` and with `--linker=legacy`

(an empty stack trace)

This happens whether I use roc dev, roc run, roc build, etc.
I am not passing --optimize, and when I pass --debug, I see:

I was expecting this file to exist:

    /home/xyz/.cache/roc/packages/github.com/roc-lang/basic-cli/releases/download/0.1.1/zAoiC9xtQPHywYk350_b7ust04BmWLW00sjb9ZPtSQk/linux-x86_64.o

However, it was not there!

If you have the platform's source code locally, you may be able to generate it by re-running this command with --prebuilt-platform=false

Running with --debug --prebuilt-platform=false produces the same error message as above.

My version is:

$ roc --version
roc nightly pre-release, built from commit 012810d on Sa 03 Dez 2022 09:07:32 UTC
$ uname -a
Linux vali 6.0.8-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 10 Nov 2022 21:14:24 +0000 x86_64 GNU/Linux

Thanks!

view this post on Zulip Folkert de Vries (Dec 08 2022 at 10:03):

does passing --linker=legacy do anything?

view this post on Zulip Folkert de Vries (Dec 08 2022 at 10:03):

the surgical linker currently does not handle debug info well

view this post on Zulip Luke Boswell (Dec 08 2022 at 10:44):

Any chance your doing AoC Day 7 there @Kevin Gillette? That is the exact error I'm currently stuck on and I'm really confused how I'm getting it.

view this post on Zulip Kevin Gillette (Dec 08 2022 at 10:47):

Folkert de Vries said:

does passing --linker=legacy do anything?

Sorry, I thought I had mentioned. With --linker=legacy It produces that same "I was expecting this file to exist" message:

I was expecting this file to exist:

    /home/xyz/.cache/roc/packages/github.com/roc-lang/basic-cli/releases/download/0.1.1/zAoiC9xtQPHywYk350_b7ust04BmWLW00sjb9ZPtSQk/linux-x86_64.o

However, it was not there!

If you have the platform's source code locally, you may be able to generate it by re-running this command with --prebuilt-platform=false

view this post on Zulip Kevin Gillette (Dec 08 2022 at 10:47):

Luke Boswell said:

Any chance your doing AoC Day 7 there Kevin Gillette? That is the exact error I'm currently stuck on and I'm really confused how I'm getting it.

This came up for me regarding day 8. Alas I have not yet attempted day 7 with Roc.

view this post on Zulip Richard Feldman (Dec 08 2022 at 11:22):

oh yeah we only include the precompiled host for surgical linking on Linux, not the one for legacy linking

view this post on Zulip Richard Feldman (Dec 08 2022 at 11:23):

but we could do both - @Anton would it take much time to do another release with everything the current one has plus the results of building on Linux with --linker=legacy so it generates the right precompiled host files for that?

view this post on Zulip Kevin Gillette (Dec 08 2022 at 17:44):

That would be awesome! I'm guessing the default linker will get debug/stack trace support at some point as well?

view this post on Zulip Brendan Hansknecht (Dec 08 2022 at 17:52):

for sure. Just need to actually handle all of the debug info.

view this post on Zulip Brendan Hansknecht (Dec 08 2022 at 17:52):

currently it is totally ignored

view this post on Zulip Luke Boswell (Dec 09 2022 at 07:58):

I'm also getting an integer subtraction overflow issue on Day 8. Confusingly I am not doing any integer subtraction anywhere. I'm having a really hard time tracking it down when I run roc test. roc check is also happy with no errors or warnings. It just crashes at runtime when it goes through this part2 code.

Here is my code for Day 8. I am reasonably confident this is something in the language or standard library as it crashes even when I reduce the code path right down to something minimal.

For example in the treesVisibleInDirection function if I follow the Left branch and replace it like the following it tests happily.

Left ->
    1

However when I replace it with the following it crashes.

Left ->
    List.range {start : At col, end : At 0}
        |> List.map \_ -> 1
        |> List.sum
── EXPECT PANICKED ────────────────────────────────────────────────── day8.roc ─

This expectation crashed while running:

278│>  expect
279│>      got = sampleState |> treesVisibleInDirection Left {row : 1, col : 2}
280│>      got == 1

The crash reported this message:

integer subtraction overflowed!

1 failed and 7 passed in 594 ms.

view this post on Zulip Anton (Dec 09 2022 at 08:17):

Richard Feldman said:

but we could do both - Anton would it take much time to do another release with everything the current one has plus the results of building on Linux with --linker=legacy so it generates the right precompiled host files for that?

That shouldn't take too long, I'll start right away :)

view this post on Zulip Kevin Gillette (Dec 09 2022 at 08:30):

@Luke Boswell your use of List.range doesn't match the signature in https://www.roc-lang.org/builtins/List#range. Are you using a forked build (or something older or newer than the documentation)?

view this post on Zulip Brian Carroll (Dec 09 2022 at 08:30):

@Luke Boswell I'm guessing but I bet the subtraction is somewhere in the implementation of List.range. Try having a look in the source code of List.roc in the repo.

view this post on Zulip Brian Carroll (Dec 09 2022 at 08:32):

This is also how to find the answer to Kevin's question!

view this post on Zulip Kevin Gillette (Dec 09 2022 at 08:32):

Actually, I don't even see List.range in the docs anymore after a page refresh. I'm guessing At and other tags (After? Before?) settles the inclusive/exclusive boundaries issue?

view this post on Zulip Kevin Gillette (Dec 09 2022 at 08:35):

Ah, I see, thanks @Brian Carroll. Those are some very excellent ergonomics for that function now!

view this post on Zulip Brendan Hansknecht (Dec 09 2022 at 08:41):

Yeah, almost certainly a bug in the new List.range. if you can dbg print col we should be able to find the exact value that is causing the crash. Would be good to add as a new unit test.

view this post on Zulip Anton (Dec 09 2022 at 09:09):

That shouldn't take too long, I'll start right away :)

Brotli compressions is ongoing...

view this post on Zulip Anton (Dec 09 2022 at 10:09):

Done: https://github.com/roc-lang/basic-cli/releases/tag/0.1.3

view this post on Zulip Luke Boswell (Dec 09 2022 at 23:13):

Ok so I've logged an issue #4726 for this and made a minimal reproduction. I'm having trouble figuring out why it works when you put the number in manually, but passing in as a parameter crashes. :shrug:


Last updated: Jul 05 2025 at 12:14 UTC