Stream: bugs

Topic: ✔ segfault on failing multi-line tests with a float def


view this post on Zulip jan kili (Mar 29 2025 at 12:50):

Can I stack trace this somehow?

app [main!] {
    cli: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br",
}

import cli.Stdout

main! = |_args|
    Stdout.line!("ignore me")

expect
    actual = 1.0
    expected = 2.0
    actual == expected
$ roc test repro.roc
Segmentation fault (core dumped)
$

view this post on Zulip jan kili (Mar 29 2025 at 12:51):

view this post on Zulip jan kili (Mar 29 2025 at 12:53):

view this post on Zulip jan kili (Mar 29 2025 at 12:58):

I'm on Debian 12 & Intel i5, with

$ roc version
roc nightly pre-release, built from commit 3da0934 on Di 04 Mär 2025 09:02:06 UTC
$

view this post on Zulip jan kili (Mar 29 2025 at 13:04):

view this post on Zulip jan kili (Mar 29 2025 at 13:08):

view this post on Zulip jan kili (Mar 29 2025 at 13:09):

Most surprising scenario yet:

expect
    actual = 1.0
    actual == 2.0

expect
    expected = 2.0
    1.0 == expected

view this post on Zulip jan kili (Mar 29 2025 at 13:13):

Another fun one:

expect
    foo = 0.5
    actual = 2 * foo
    actual == 2.0

(but not if I delete foo and make actual = 2 * 0.5)

view this post on Zulip jan kili (Mar 29 2025 at 13:18):

Okay, I think I've isolated the behavior - it seems to be if a failing test has more than one def where one is a float.

This segfaults:

expect
    foo = 1.0
    bar = "2.0"
    Num.to_str(foo) == bar

view this post on Zulip jan kili (Mar 29 2025 at 13:20):

But this fails normally:

expect
    foo = 1.0
    Num.to_str(foo) == "2.0"

view this post on Zulip Anton (Mar 29 2025 at 14:20):

Hmm, I can not reproduce on Ubuntu 24.04 with the same commit, but let me try the actual release.

view this post on Zulip Anton (Mar 29 2025 at 14:23):

Ok, it does happen with the actual release

view this post on Zulip Anton (Mar 29 2025 at 14:26):

❯ valgrind ./roc test jantemp.roc --linker=legacy
==40714== Memcheck, a memory error detector
==40714== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==40714== Using Valgrind-3.22.0 and LibVEX; rerun with -h for copyright info
==40714== Command: ./roc test jantemp.roc --linker=legacy
==40714==
==40714== Warning: set address range perms: large range [0x27592000000, 0x275d2000000) (defined)

view this post on Zulip Anton (Mar 29 2025 at 14:26):

Valgrind is taking a long time...

view this post on Zulip Anton (Mar 29 2025 at 14:36):

I have only seen "Warning: set address range perms: large range" once so I do expect that is related to the segfault.

view this post on Zulip Anton (Mar 29 2025 at 14:41):

I need to build a debug version of basic-cli to prevent valgrind from giving me all ???

view this post on Zulip Anton (Mar 29 2025 at 15:15):

Right, the ??? refer to things inside the Roc binary, not basic-cli

view this post on Zulip Anton (Mar 29 2025 at 15:16):

❯ valgrind roc test examples/hello-world.roc --linker=legacy
==46699== Memcheck, a memory error detector
==46699== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==46699== Using Valgrind-3.22.0 and LibVEX; rerun with -h for copyright info
==46699== Command: roc test examples/hello-world.roc --linker=legacy
==46699==
==46699== Warning: set address range perms: large range [0x3692a000000, 0x3696a000000) (defined)
==46699== Conditional jump or move depends on uninitialised value(s)
==46699==    at 0xDC73EC: ??? (in /home/username/Downloads/temp3/roc_nightly-linux_x86_64-2025-03-04-3da0934/roc)
==46699==    by 0xDC8D6F: ??? (in /home/username/Downloads/temp3/roc_nightly-linux_x86_64-2025-03-04-3da0934/roc)
==46699==    by 0xDBFBB8: ??? (in /home/username/Downloads/temp3/roc_nightly-linux_x86_64-2025-03-04-3da0934/roc)
==46699==    by 0xDBC6CD: ??? (in /home/username/Downloads/temp3/roc_nightly-linux_x86_64-2025-03-04-3da0934/roc)
==46699==    by 0xD562D7: ??? (in /home/username/Downloads/temp3/roc_nightly-linux_x86_64-2025-03-04-3da0934/roc)
==46699==    by 0x996EFB: ??? (in /home/username/Downloads/temp3/roc_nightly-linux_x86_64-2025-03-04-3da0934/roc)
==46699==    by 0x83B55F: ??? (in /home/username/Downloads/temp3/roc_nightly-linux_x86_64-2025-03-04-3da0934/roc)
==46699==    by 0x82E182: ??? (in /home/username/Downloads/temp3/roc_nightly-linux_x86_64-2025-03-04-3da0934/roc)
==46699==    by 0x82E1A2: ??? (in /home/username/Downloads/temp3/roc_nightly-linux_x86_64-2025-03-04-3da0934/roc)
==46699==    by 0x1423A69: ??? (in /home/username/Downloads/temp3/roc_nightly-linux_x86_64-2025-03-04-3da0934/roc)
==46699==    by 0x843744: ??? (in /home/username/Downloads/temp3/roc_nightly-linux_x86_64-2025-03-04-3da0934/roc)
==46699==    by 0x5EB11C9: (below main) (libc_start_call_main.h:58)
==46699==
...
==46699== Conditional jump or move depends on uninitialised value(s)
==46699==    at 0x733001: ??? (in /home/username/Downloads/temp3/roc_nightly-linux_x86_64-2025-03-04-3da0934/roc)
==46699==    by 0x751339: ??? (in /home/username/Downloads/temp3/roc_nightly-linux_x86_64-2025-03-04-3da0934/roc)
==46699==    by 0x75049C: ??? (in /home/username/Downloads/temp3/roc_nightly-linux_x86_64-2025-03-04-3da0934/roc)
==46699==    by 0x722319: ??? (in /home/username/Downloads/temp3/roc_nightly-linux_x86_64-2025-03-04-3da0934/roc)
==46699==    by 0x74C06B: ??? (in /home/username/Downloads/temp3/roc_nightly-linux_x86_64-2025-03-04-3da0934/roc)
==46699==    by 0x73FDFA: ??? (in /home/username/Downloads/temp3/roc_nightly-linux_x86_64-2025-03-04-3da0934/roc)
==46699==    by 0xBBE21E: ??? (in /home/username/Downloads/temp3/roc_nightly-linux_x86_64-2025-03-04-3da0934/roc)
==46699==    by 0xBF6EB1: ??? (in /home/username/Downloads/temp3/roc_nightly-linux_x86_64-2025-03-04-3da0934/roc)
==46699==    by 0xBF5A1B: ??? (in /home/username/Downloads/temp3/roc_nightly-linux_x86_64-2025-03-04-3da0934/roc)
==46699==    by 0x10F78AF: ??? (in /home/username/Downloads/temp3/roc_nightly-linux_x86_64-2025-03-04-3da0934/roc)
==46699==    by 0x997889: ??? (in /home/username/Downloads/temp3/roc_nightly-linux_x86_64-2025-03-04-3da0934/roc)
==46699==    by 0x83B55F: ??? (in /home/username/Downloads/temp3/roc_nightly-linux_x86_64-2025-03-04-3da0934/roc)
==46699==
==46699==
==46699== Process terminating with default action of signal 11 (SIGSEGV)
==46699==  General Protection Fault
==46699==    at 0x10F9DF8: ??? (in /home/username/Downloads/temp3/roc_nightly-linux_x86_64-2025-03-04-3da0934/roc)
==46699==    by 0x94F8EE: ??? (in /home/username/Downloads/temp3/roc_nightly-linux_x86_64-2025-03-04-3da0934/roc)
==46699==    by 0x9989EB: ??? (in /home/username/Downloads/temp3/roc_nightly-linux_x86_64-2025-03-04-3da0934/roc)
==46699==    by 0x83B55F: ??? (in /home/username/Downloads/temp3/roc_nightly-linux_x86_64-2025-03-04-3da0934/roc)
==46699==    by 0x82E182: ??? (in /home/username/Downloads/temp3/roc_nightly-linux_x86_64-2025-03-04-3da0934/roc)
==46699==    by 0x82E1A2: ??? (in /home/username/Downloads/temp3/roc_nightly-linux_x86_64-2025-03-04-3da0934/roc)
==46699==    by 0x1423A69: ??? (in /home/username/Downloads/temp3/roc_nightly-linux_x86_64-2025-03-04-3da0934/roc)
==46699==    by 0x843744: ??? (in /home/username/Downloads/temp3/roc_nightly-linux_x86_64-2025-03-04-3da0934/roc)
==46699==    by 0x5EB11C9: (below main) (libc_start_call_main.h:58)
==46699==
==46699== HEAP SUMMARY:
==46699==     in use at exit: 332,318 bytes in 2,248 blocks
==46699==   total heap usage: 203,901 allocs, 201,653 frees, 56,084,245 bytes allocated
==46699==
==46699== LEAK SUMMARY:
==46699==    definitely lost: 0 bytes in 0 blocks
==46699==    indirectly lost: 0 bytes in 0 blocks
==46699==      possibly lost: 3,584 bytes in 5 blocks
==46699==    still reachable: 328,734 bytes in 2,243 blocks
==46699==         suppressed: 0 bytes in 0 blocks
==46699== Rerun with --leak-check=full to see details of leaked memory
==46699==
==46699== Use --track-origins=yes to see where uninitialised values come from
==46699== For lists of detected and suppressed errors, rerun with: -s
==46699== ERROR SUMMARY: 561 errors from 22 contexts (suppressed: 0 from 0)
Segmentation fault (core dumped)

view this post on Zulip Anton (Mar 29 2025 at 16:08):

Valgrind is taking forever...

view this post on Zulip Brendan Hansknecht (Mar 29 2025 at 16:11):

You could try --profiling

view this post on Zulip Anton (Mar 29 2025 at 16:34):

I can't run the produced binary standalone because I need the expects to run so I think --profiling will not help here?

view this post on Zulip Brendan Hansknecht (Mar 29 2025 at 16:46):

Ah....hmm

view this post on Zulip Brendan Hansknecht (Mar 29 2025 at 16:46):

You could try putting the expect in a main function and then compiling a debug build?

view this post on Zulip Brendan Hansknecht (Mar 29 2025 at 16:46):

Cause expects run in debug builds

view this post on Zulip Anton (Mar 29 2025 at 17:23):

I believe all expects require the roc compiler, and if the roc compiler is involved it will be slow on valgrind. But anyway valgrind is done, I just need to try building a debug nightly on the typical CI machine so I can both reproduce the segfault and clear up the ???.

view this post on Zulip Brendan Hansknecht (Mar 29 2025 at 17:35):

Hmm...maybe. I forget the state

view this post on Zulip Anton (Mar 29 2025 at 18:14):

Alright, I got some useful valgrind output:
nice_valgrind_output.txt

view this post on Zulip Anton (Mar 29 2025 at 18:15):

I didn't need the CI machine, all I needed to reproduce locally was building roc with:

 RUSTFLAGS="-C target-cpu=x86-64" cargo build --profile=release-with-lto --bin roc

view this post on Zulip Brendan Hansknecht (Mar 29 2025 at 18:17):

We are reading the shared memory wrong

view this post on Zulip Brendan Hansknecht (Mar 29 2025 at 18:17):

Must be getting a pointer that is pointing to total garbage as a result

view this post on Zulip Brendan Hansknecht (Mar 29 2025 at 18:18):

I would probably label this as a won't fix (kinda).

view this post on Zulip Brendan Hansknecht (Mar 29 2025 at 18:18):

We want to rip out that system

view this post on Zulip Brendan Hansknecht (Mar 29 2025 at 18:18):

We already did so for dbg, but we have not done so for expect.

view this post on Zulip Brendan Hansknecht (Mar 29 2025 at 18:18):

It has a number of bugs.

view this post on Zulip Brendan Hansknecht (Mar 29 2025 at 18:19):

Also, relevant stack trace snippet:

==92315== Process terminating with default action of signal 11 (SIGSEGV)
==92315==  General Protection Fault
==92315==    at 0x119F1E8: roc_repl_expect::get_values (in /home/username/gitrepos/roc/target/release-with-lto/roc)
==92315==    by 0x9F4C8E: roc_repl_expect::run::render_expect_failure (in /home/username/gitrepos/roc/target/release-with-lto/roc)
==92315==    by 0xA3DDDB: roc_cli::test (in /home/username/gitrepos/roc/target/release-with-lto/roc)
==92315==    by 0x8E090F: roc::main (in /home/username/gitrepos/roc/target/release-with-lto/roc)
==92315==    by 0x8D3532: std::sys_common::backtrace::__rust_begin_short_backtrace (in /home/username/gitrepos/roc/target/release-with-lto/roc)
==92315==    by 0x8D3552: std::rt::lang_start::{{closure}} (in /home/username/gitrepos/roc/target/release-with-lto/roc)
==92315==    by 0x14C8E59: std::rt::lang_start_internal (in /home/username/gitrepos/roc/target/release-with-lto/roc)
==92315==    by 0x8E8AF4: main (in /home/username/gitrepos/roc/target/release-with-lto/roc)

view this post on Zulip jan kili (Mar 30 2025 at 15:58):

Stack trace acquired! Thanks for debugging, y'all. I understand the wontfix during the compiler rewrite.

view this post on Zulip jan kili (Mar 30 2025 at 15:58):

Note to self - avoid using float defs in expects.

view this post on Zulip Notification Bot (Mar 30 2025 at 15:59):

JanCVanB has marked this topic as resolved.

view this post on Zulip Anton (May 19 2025 at 12:12):

I've made a general issue for this problem #7799


Last updated: Jul 06 2025 at 12:14 UTC