weakmaptest or disclaimtest failure if malloc redirect and gc-debug
Source: master (a863ed338d)
Build link: https://github.com/bdwgc/bdwgc/actions/runs/18986864403/job/54232316624
Host: Ubuntu 24.04 / x86_64
Build command: zig build -Dtarget=native -Dlinkage=static -Dbuild_cord=true -Ddisable_handle_fork=false -Denable_cplusplus=true -Denable_gc_assertions=true -Denable_gc_debug=true -Denable_large_config=false -Denable_munmap=false -Denable_parallel_mark=true -Denable_redirect_malloc=true -Denable_rwlock=false -Denable_thread_local_alloc=true -Denable_threads=true -Denable_werror test
Also happens with -Denable_munmap=true.
Somewhat related: #613
Source: master (abbe389)
Build: https://github.com/bdwgc/bdwgc/actions/runs/19274603415/job/55111265890
Host: Linux/x86_64
Command: zig build -Dtarget=native -Dlinkage=static -Denable_cplusplus=true -Denable_gc_assertions=true -Denable_gc_debug=true -Denable_munmap=false -Denable_redirect_malloc=true -Denable_rwlock=true test
Reproduced disclaim_test failure locally ("h").
Source: release-7_6 (b5c41e957).
Host: Ubuntu/x86_64
Command: ./configure --enable-redirect-malloc --enable-gc-debug --enable-cplusplus --enable-gc-assertions && make -j check CFLAGS_EXTRA="-D _FORTIFY_SOURCE=2"
(gdb) bt
#0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:44
#1 __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78
#2 __GI___pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3 0x00007c61c464527e in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4 0x00007c61c46288ff in __GI_abort () at ./stdlib/abort.c:79
#5 0x00007c61bcd977ef in uw_init_context_1 (context=context@entry=0x7ffe4627bd20, outer_cfa=outer_cfa@entry=0x7ffe4627bf50,
outer_ra=0x7c61c4735eb3 <__GI___backtrace+99>) at ../../../src/libgcc/unwind-dw2.c:1336
#6 0x00007c61bcdb6896 in _Unwind_Backtrace (trace=0x7c61c4735db0 <backtrace_helper>, trace_argument=0x7ffe4627bf50)
at ../../../src/libgcc/unwind.inc:296
#7 0x00007c61c4735eb3 in __GI___backtrace (array=array@entry=0x7ffe4627bfa0, size=size@entry=9) at ./debug/backtrace.c:78
#8 0x00007c61c4874c5b in GC_save_callers (info=info@entry=0x7c61c45d7020) at os_dep.c:4528
#9 0x00007c61c4864eb2 in store_debug_info (p=0x7c61c45d7000, lb=lb@entry=4096, fn=fn@entry=0x7c61c4880212 "GC_debug_malloc",
s=s@entry=0x7c61c4880278 "unknown", i=i@entry=0) at dbg_mlc.c:314
#10 0x00007c61c4865088 in GC_debug_malloc (lb=lb@entry=4096, s=s@entry=0x7c61c4880278 "unknown", i=i@entry=0) at dbg_mlc.c:541
#11 0x00007c61c486bc92 in malloc (lb=lb@entry=4096) at malloc.c:405
#12 0x00007c61c46851b5 in __GI__IO_file_doallocate (fp=0x7c61c48045c0 <_IO_2_1_stdout_>) at ./libio/filedoalloc.c:101
#13 0x00007c61c4695524 in __GI__IO_doallocbuf (fp=fp@entry=0x7c61c48045c0 <_IO_2_1_stdout_>) at ./libio/libioP.h:1030
#14 0x00007c61c4692f90 in _IO_new_file_overflow (f=0x7c61c48045c0 <_IO_2_1_stdout_>, ch=-1) at ./libio/fileops.c:745
#15 0x00007c61c4693aaf in _IO_new_file_xsputn (n=23, data=<optimized out>, f=<optimized out>) at ./libio/libioP.h:1030
#16 _IO_new_file_xsputn (f=0x7c61c48045c0 <_IO_2_1_stdout_>, data=<optimized out>, n=23) at ./libio/fileops.c:1197
#17 0x00007c61c4687c5d in __GI__IO_puts (str=str@entry=0x5d9821997309 "Threaded disclaim test.") at ./libio/libioP.h:1030
#18 0x00005d982199530f in printf (__fmt=<synthetic pointer>) at /usr/include/x86_64-linux-gnu/bits/stdio2.h:86
#19 main () at tests/disclaim_test.c:244
The solution could be to skip backtrace call if called from malloc() when the later is called from libc.
Related (most probably): #816