Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIGSEGV in static multi-threaded build with redirect malloc #693

Open
ivmai opened this issue Dec 28, 2024 · 2 comments
Open

SIGSEGV in static multi-threaded build with redirect malloc #693

ivmai opened this issue Dec 28, 2024 · 2 comments

Comments

@ivmai
Copy link
Owner

ivmai commented Dec 28, 2024

Source: master (067ed9b)
Host: FreeBSD-15.0/aarch64
Compiler: clang
How to reproduce: mkdir out && cd out && cmake -Dbuild_tests=ON -Denable_redirect_malloc=ON -DBUILD_SHARED_LIBS=OFF .. && cmake --build . && ctest
Note: not observed without -DBUILD_SHARED_LIBS=OFF.
gdb output:

Program received signal SIGSEGV, Segmentation fault.
Address not mapped to object.
_thr_setcancelstate (state=state@entry=1, oldstate=oldstate@entry=0xffffffffd66c)
    at /usr/src/lib/libthr/thread/thr_cancel.c:88
88              oldval = curthread->cancel_enable;
(gdb) bt
#0  _thr_setcancelstate (state=state@entry=1, oldstate=oldstate@entry=0xffffffffd66c)
    at /usr/src/lib/libthr/thread/thr_cancel.c:88
#1  0x000000000022e098 in GC_init () at bdwgc/misc.c:1080
#2  0x0000000000229270 in GC_generic_malloc_inner_small (lb=lb@entry=1664, k=k@entry=1)
    at bdwgc/malloc.c:181
#3  0x0000000000229388 in GC_generic_malloc_aligned (lb=1664, k=1, flags=<optimized out>, align_m1=0)
    at bdwgc/malloc.c:251
#4  0x000000000022982c in GC_malloc_kind_aligned_global (lb=1664, k=1, align_m1=0) at bdwgc/malloc.c:373
#5  0x00000000402e81f0 in _thr_alloc (curthread=0x0, curthread@entry=0xffffffffd7e0)
    at /usr/src/lib/libthr/thread/thr_list.c:153
#6  0x00000000402e6fa0 in _libpthread_init (curthread=0x0) at /usr/src/lib/libthr/thread/thr_init.c:336
#7  0x0000000040271dec in objlist_call_init (list=list@entry=0xffffffffe460, lockstate=<optimized out>,
    lockstate@entry=0xffffffffe250) at /usr/src/libexec/rtld-elf/rtld.c:3118
#8  0x0000000040270ae0 in _rtld (sp=<optimized out>, exit_proc=<optimized out>, objp=<optimized out>)
    at /usr/src/libexec/rtld-elf/rtld.c:964
#9  0x000000004026dec4 in rtld_start () at /usr/src/libexec/rtld-elf/aarch64/rtld_start.S:41
@ivmai
Copy link
Owner Author

ivmai commented Dec 28, 2024

Note: we cannot redirect GC_malloc (GC_malloc_kind_aligned_global) to sbrk if GC is not initialized because sbrk is not available.

@ivmai
Copy link
Owner Author

ivmai commented Dec 28, 2024

Same observed on CheriBSD.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant