Skip to content

T4221 fails with assertion failure when built with -debug -threaded

Currently the T4221 fails with an assertion failure when built with the -debug RTS:

$ _build/stage1/bin/ghc testsuite/tests/ffi/should_run/T4221.hs testsuite/tests/ffi/should_run/T4221_c.c -threaded -debug -rtsopts -optc-g3 -g3
$ testsuite/tests/ffi/should_run/T4221
start
step 0.0: 0.0
step 1.0: 1.0
step 2.0: 2.0
step 3.0: 3.0
step 4.0: 4.0
...
step 996.0: 996.0
step 997.0: 997.0
step 998.0: 998.0
step 999.0: 999.0
step 1000.0: 1000.0
done
T4221: internal error: ASSERTION FAILED: file rts/adjustor/AdjustorPool.c, line 271

Stack trace:
                  0x81fcc7    set_initial_registers (rts/Libdw.c:294.57)
            0x7fefb1c19478    dwfl_thread_getframes (/nix/store/k5knw5l7gcbb6dfrnpr1ghkfpj0s0v01-elfutils-0.187/lib/libdw-0.187.so)
            0x7fefb1c18fbb    get_one_thread_cb (/nix/store/k5knw5l7gcbb6dfrnpr1ghkfpj0s0v01-elfutils-0.187/lib/libdw-0.187.so)
            0x7fefb1c192e2    dwfl_getthreads (/nix/store/k5knw5l7gcbb6dfrnpr1ghkfpj0s0v01-elfutils-0.187/lib/libdw-0.187.so)
            0x7fefb1c19827    dwfl_getthread_frames (/nix/store/k5knw5l7gcbb6dfrnpr1ghkfpj0s0v01-elfutils-0.187/lib/libdw-0.187.so)
                  0x81fbb1    libdwGetBacktrace (rts/Libdw.c:263.15)
                  0x7cbf4b    rtsFatalInternalErrorFn (rts/RtsMessages.c:175.30)
                  0x7cbb0a    barf (rts/RtsMessages.c:49.4)
                  0x7cbb6d    errorBelch (rts/RtsMessages.c:68.5)
                  0x818392    free_adjustor (rts/adjustor/AdjustorPool.c:273.5)
                  0x805856    freeHaskellFunctionPtr (rts/adjustor/NativeAmd64.c:110.5)
                  0x4086bb    free_fn_blob (testsuite/tests/ffi/should_run/T4221_c.c:24.3)
                  0x7e2fda    runCFinalizers (rts/Weak.c:32.14)
                  0x7e3394    runSomeFinalizers (rts/Weak.c:249.9)
                  0x7edb3f    doIdleGCWork (rts/sm/GC.c:2207.12)
                  0x7d3c48    scheduleDoGC (rts/Schedule.c:1871.9)
                  0x7d55e7    exitScheduler (rts/Schedule.c:2755.9)
                  0x7cc6e3    hs_exit_ (rts/RtsStartup.c:478.5)
                  0x7cc8f7    shutdownHaskellAndExit (rts/RtsStartup.c:666.9)
                  0x7cba55    barf (rts/RtsMessages.c:45.0)
                  0x4087d2    (null) (/opt/exp/ghc/ghc-landing/testsuite/tests/ffi/should_run/T4221)
            0x7fefb1ca6237    __libc_start_call_main (/nix/store/lyl6nysc3i3aqhj6shizjgj0ibnf1pvg-glibc-2.34-210/lib/libc.so.6)
            0x7fefb1ca62f5    __libc_start_main@@GLIBC_2.34 (/nix/store/lyl6nysc3i3aqhj6shizjgj0ibnf1pvg-glibc-2.34-210/lib/libc.so.6)
                  0x4070d1    _start (../sysdeps/x86_64/start.S:118.0)

    (GHC version 9.5.20220617 for x86_64_unknown_linux)
    Please report this as a GHC bug:  https://www.haskell.org/ghc/reportabug
Aborted (core dumped)

I believe that this is a latent bug exposed by the fact that AdjustorPool (see !6155 (closed)) now checks for double-freeing.

Edited by Ben Gamari
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information