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)
$
==
to !=
.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
$
expect 1.0 == 2.0
a
& b
.Most surprising scenario yet:
expect
actual = 1.0
actual == 2.0
expect
expected = 2.0
1.0 == expected
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
)
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
But this fails normally:
expect
foo = 1.0
Num.to_str(foo) == "2.0"
Hmm, I can not reproduce on Ubuntu 24.04 with the same commit, but let me try the actual release.
Ok, it does happen with the actual release
❯ 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)
Valgrind is taking a long time...
I have only seen "Warning: set address range perms: large range
" once so I do expect that is related to the segfault.
I need to build a debug version of basic-cli to prevent valgrind from giving me all ???
Right, the ???
refer to things inside the Roc binary, not basic-cli
❯ 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)
Valgrind is taking forever...
You could try --profiling
I can't run the produced binary standalone because I need the expects to run so I think --profiling
will not help here?
Ah....hmm
You could try putting the expect in a main function and then compiling a debug build?
Cause expects run in debug builds
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 ???
.
Hmm...maybe. I forget the state
Alright, I got some useful valgrind output:
nice_valgrind_output.txt
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
We are reading the shared memory wrong
Must be getting a pointer that is pointing to total garbage as a result
I would probably label this as a won't fix (kinda).
We want to rip out that system
We already did so for dbg
, but we have not done so for expect
.
It has a number of bugs.
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)
Stack trace acquired! Thanks for debugging, y'all. I understand the wontfix during the compiler rewrite.
Note to self - avoid using float defs in expect
s.
JanCVanB has marked this topic as resolved.
I've made a general issue for this problem #7799
Last updated: Jul 06 2025 at 12:14 UTC