Stream: contributing

Topic: dec.to_str test failing in debug mode on main


view this post on Zulip Norbert Hajagos (Jan 10 2025 at 14:27):

Hi! I just turned on all 3 debug flags in /crates/compiler/builtins/bitcode/src/utils.zig on the main branch.

const DEBUG_INCDEC = true;
const DEBUG_TESTING_ALLOC = true;
const DEBUG_ALLOC = true;

and ran zig build test in /crates/compiler/builtins/bitcode.

That resulted in a big message, which is pasted below. Can make an issue for it on GH, if you wish, but I don't really know what's the problem, so the issue wouldn't have more advice on solving it than this message.

view this post on Zulip Norbert Hajagos (Jan 10 2025 at 14:27):

test
└─ run test failure
+ alloc *anyopaque@7ffff7dc4008: 47 bytes
+ allocated u8@7ffff7dc4008 (39 bytes with alignment 8)
| decrement isize@7ffff7dc4008: thread 46986 panic: integer overflow
/home/ez/code/roc/crates/compiler/builtins/bitcode/src/utils.zig:394:38: 0x10c4bf6 in decref (test)
                    const newH = new - REFCOUNT_ONE + 1;
                                     ^
/home/ez/code/roc/crates/compiler/builtins/bitcode/src/str.zig:175:25: 0x1097d83 in decref (test)
            utils.decref(self.getAllocationPtr(), self.capacity_or_alloc_ptr, RocStr.alignment, false);
                        ^
/home/ez/code/roc/crates/compiler/builtins/bitcode/src/dec.zig:1146:29: 0x10a9130 in test.to_str: 12345678912345678912.111111111111111111 (max number of digits) (test)
    defer res_roc_str.decref();
                            ^
/nix/store/5yk32f31879lfsnyv0yhl0af0v2dz9dz-zig-0.13.0/lib/zig/compiler/test_runner.zig:95:29: 0x10d694a in mainServer (test)
                test_fn.func() catch |err| switch (err) {
                            ^
/nix/store/5yk32f31879lfsnyv0yhl0af0v2dz9dz-zig-0.13.0/lib/zig/compiler/test_runner.zig:35:26: 0x10a1ade in main (test)
        return mainServer() catch @panic("internal test runner failure");
                         ^
/nix/store/5yk32f31879lfsnyv0yhl0af0v2dz9dz-zig-0.13.0/lib/zig/std/start.zig:514:22: 0x10a15e9 in main (test)
            root.main();
                     ^
???:?:?: 0x7ffff7df214d in ??? (libc.so.6)
Unwind information for `libc.so.6:0x7ffff7df214d` was not available, trace may be incomplete


error: while executing test 'dec.test.to_str: 12345678912345678912.111111111111111111 (max number of digits)', the following command terminated with signal 6 (expected exited with code 0):
/home/ez/code/roc/crates/compiler/builtins/bitcode/.zig-cache/o/406f6dc9a33e29d7612c63c566292d2c/test --listen=-
Build Summary: 1/3 steps succeeded; 1 failed; 175/175 tests passed (disable with --summary none)
test transitive failure
└─ run test failure
error: the following build command failed with exit code 1:
/home/ez/code/roc/crates/compiler/builtins/bitcode/.zig-cache/o/2f0a5f6d4511644775d1346b2b43d59c/build /nix/store/5yk32f31879lfsnyv0yhl0af0v2dz9dz-zig-0.13.0/bin/zig /home/ez/code/roc/crates/compiler/builtins/bitcode /home/ez/code/roc/crates/compiler/builtins/bitcode/.zig-cache /home/ez/.cache/zig --seed 0x8d8f0680 -Z7b11edb732d403d4 test

view this post on Zulip Anthony Bullard (Jan 10 2025 at 14:32):

That means that More than likely newH is a unsigned integer that's underflowing

view this post on Zulip Brendan Hansknecht (Jan 10 2025 at 20:17):

Oh, that code is outdated now

view this post on Zulip Brendan Hansknecht (Jan 10 2025 at 20:17):

Must have missed it with the refcount changes if it isn't used in the default path

view this post on Zulip Brendan Hansknecht (Jan 10 2025 at 20:17):

Basically newH doesn't have meaning anymore and should just be new

view this post on Zulip Brendan Hansknecht (Jan 10 2025 at 20:18):

Probably is only used for printing

view this post on Zulip Brendan Hansknecht (Jan 10 2025 at 20:20):

Yeah, just delete newH and oldH throughout that file and use new and old instead.

view this post on Zulip Norbert Hajagos (Jan 10 2025 at 20:37):

Yup, everything works fine that way. Here is the quick fix https://github.com/roc-lang/roc/pull/7498

view this post on Zulip Brendan Hansknecht (Jan 11 2025 at 04:36):

Just realized that my refcount PR hasn't landed yet. So that old code should have been correct

view this post on Zulip Brendan Hansknecht (Jan 11 2025 at 04:36):

Anyway, not a big deal, just enabled auto submit on my refcount PR. So this new change is correct now anyway.

view this post on Zulip Norbert Hajagos (Jan 11 2025 at 08:07):

This hasn't happened to me yet. Removing a bug that instead, should have been corrected, but by the time we realize, it becomes something that should be removed :big_smile:


Last updated: Jul 06 2025 at 12:14 UTC