Bug 1950244
| Summary: | Miminal program fail with address sanitizer error failed to allocate 0x0 (0) bytes of SetAlternateSignalStack | ||
|---|---|---|---|
| Product: | [Fedora] Fedora | Reporter: | Lukas Slebodnik <lslebodn> |
| Component: | gcc | Assignee: | Jakub Jelinek <jakub> |
| Status: | CLOSED RAWHIDE | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
| Severity: | unspecified | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | rawhide | CC: | aoliva, arjun, codonell, dj, dmalcolm, fweimer, jakub, jwakely, law, mcermak, mfabian, mpolacek, msebor, nickc, pfrankli, rth, sipoyare |
| Target Milestone: | --- | ||
| Target Release: | --- | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | gcc-11.0.1-0.5.fc35 | Doc Type: | If docs needed, set a value |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2021-04-20 14:37:03 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
This error comes from Address Sanitizer, so reassigning to gcc. workaround seems to be disable option use_sigaltstack
Surprisingly, leak detection fails for minimal code as well.
Shall I file a new bug for that? or is it related?
sh-5.1$ printf "int main(void) { return 0; }" > test.c
sh-5.1$ gcc -o test test.c
sh-5.1$ LD_PRELOAD=`rpm -ql libasan | grep so | tail -n1` ASAN_OPTIONS=use_sigaltstack=0 ./test
==11881==LeakSanitizer has encountered a fatal error.
==11881==HINT: For debugging, try setting environment variable LSAN_OPTIONS=verbosity=1:log_threads=1
==11881==HINT: LeakSanitizer does not work under ptrace (strace, gdb, etc)
sh-5.1$ LD_PRELOAD=`rpm -ql libasan | grep so | tail -n1` ASAN_OPTIONS=use_sigaltstack=0 LSAN_OPTIONS=verbosity=1:log_threads=1 ./test
==11887==AddressSanitizer: failed to intercept '__isoc99_printf'
'==11887==AddressSanitizer: failed to intercept '__isoc99_sprintf'
'==11887==AddressSanitizer: failed to intercept '__isoc99_snprintf'
'==11887==AddressSanitizer: failed to intercept '__isoc99_fprintf'
'==11887==AddressSanitizer: failed to intercept '__isoc99_vprintf'
'==11887==AddressSanitizer: failed to intercept '__isoc99_vsprintf'
'==11887==AddressSanitizer: failed to intercept '__isoc99_vsnprintf'
'==11887==AddressSanitizer: failed to intercept '__isoc99_vfprintf'
'==11887==AddressSanitizer: failed to intercept 'xdr_quad_t'
'==11887==AddressSanitizer: failed to intercept 'xdr_u_quad_t'
'==11887==AddressSanitizer: failed to intercept 'xdr_destroy'
'==11887==AddressSanitizer: failed to intercept 'crypt'
'==11887==AddressSanitizer: failed to intercept 'crypt_r'
'==11887==AddressSanitizer: libc interceptors initialized
|| `[0x10007fff8000, 0x7fffffffffff]` || HighMem ||
|| `[0x02008fff7000, 0x10007fff7fff]` || HighShadow ||
|| `[0x00008fff7000, 0x02008fff6fff]` || ShadowGap ||
|| `[0x00007fff8000, 0x00008fff6fff]` || LowShadow ||
|| `[0x000000000000, 0x00007fff7fff]` || LowMem ||
MemToShadow(shadow): 0x00008fff7000 0x000091ff6dff 0x004091ff6e00 0x02008fff6fff
redzone=16
max_redzone=2048
quarantine_size_mb=256M
thread_local_quarantine_size_kb=1024K
malloc_context_size=30
SHADOW_SCALE: 3
SHADOW_GRANULARITY: 8
SHADOW_OFFSET: 0x7fff8000
==11887==Installed the sigaction for signal 11
==11887==Installed the sigaction for signal 7
==11887==Installed the sigaction for signal 8
==11887==T0: stack [0x7fffefb2f000,0x7ffff032f000) size 0x800000; local=0x7ffff032d6bc
==11887==AddressSanitizer Init done
==11888==Could not attach to thread 11887 (errno 1).
==11888==Failed suspending threads.
==11887==LeakSanitizer has encountered a fatal error.
==11887==HINT: For debugging, try setting environment variable LSAN_OPTIONS=verbosity=1:log_threads=1
==11887==HINT: LeakSanitizer does not work under ptrace (strace, gdb, etc)
I think Leak Sanitizer just doesn't work with glibc because it tries to access internals behind glibc's back. The sigaltstack issues is probably this: static const uptr kAltStackSize = SIGSTKSZ * 4; // SIGSTKSZ is not enough. And this is no longer a static initializer with current glibc, and Address Sanitizer appears to access the variable before the initializer is evaluated. Should be fixed already in gcc-11.0.1-0.5.fc35. |
Description of problem: I wanted to play a bit with ASAN on rawhide but lot of things fail even minimal program with noop logic I am not sure whether bug is in glibc or gcc/libasan therefore starting with glibc due to noop logic in sample program Version-Release number of selected component (if applicable): sh$ rpm -q gcc libasan glibc gcc-11.0.1-0.4.fc35.x86_64 libasan-11.0.1-0.4.fc35.x86_64 glibc-2.33.9000-2.fc35.x86_64 How reproducible: Deterministic Steps to Reproduce: 1. dnf install -y gcc libasan 2. printf "int main(void) { return 0; }" > test.c 3. gcc -o test -g3 -O0 -fsanitize=address -fno-omit-frame-pointer test.c 4. ./test Actual results: [build@eadc9aeff370 sssd]$ printf "int main(void) { return 0; }" > test.c [build@eadc9aeff370 sssd]$ gcc -o test -g3 -O0 -fsanitize=address -fno-omit-frame-pointer test.c [build@eadc9aeff370 sssd]$ ./test ==11818==ERROR: AddressSanitizer failed to allocate 0x0 (0) bytes of SetAlternateSignalStack (error code: 22) ==11818==Process memory map follows: 0x000000400000-0x000000401000 /home/build/sssd/test 0x000000401000-0x000000402000 /home/build/sssd/test 0x000000402000-0x000000403000 /home/build/sssd/test 0x000000403000-0x000000404000 /home/build/sssd/test 0x000000404000-0x000000405000 /home/build/sssd/test 0x00007fff7000-0x00008fff7000 0x00008fff7000-0x02008fff7000 0x02008fff7000-0x10007fff8000 0x7f05da5b6000-0x7f05da920000 0x7f05da920000-0x7f05da923000 /usr/lib64/libgcc_s-11-20210405.so.1 0x7f05da923000-0x7f05da935000 /usr/lib64/libgcc_s-11-20210405.so.1 0x7f05da935000-0x7f05da938000 /usr/lib64/libgcc_s-11-20210405.so.1 0x7f05da938000-0x7f05da939000 /usr/lib64/libgcc_s-11-20210405.so.1 0x7f05da939000-0x7f05da93a000 /usr/lib64/libgcc_s-11-20210405.so.1 0x7f05da93a000-0x7f05da93b000 /usr/lib64/libgcc_s-11-20210405.so.1 0x7f05da93b000-0x7f05da94a000 /usr/lib64/libm-2.33.9000.so 0x7f05da94a000-0x7f05da9e4000 /usr/lib64/libm-2.33.9000.so 0x7f05da9e4000-0x7f05daa7c000 /usr/lib64/libm-2.33.9000.so 0x7f05daa7c000-0x7f05daa7d000 /usr/lib64/libm-2.33.9000.so 0x7f05daa7d000-0x7f05daa7e000 /usr/lib64/libm-2.33.9000.so 0x7f05daa7e000-0x7f05daa7f000 /usr/lib64/libm-2.33.9000.so 0x7f05daa7f000-0x7f05daa81000 0x7f05daa81000-0x7f05dab1a000 /usr/lib64/libstdc++.so.6.0.29 0x7f05dab1a000-0x7f05dac1c000 /usr/lib64/libstdc++.so.6.0.29 0x7f05dac1c000-0x7f05dac8f000 /usr/lib64/libstdc++.so.6.0.29 0x7f05dac8f000-0x7f05dac9a000 /usr/lib64/libstdc++.so.6.0.29 0x7f05dac9a000-0x7f05dac9d000 /usr/lib64/libstdc++.so.6.0.29 0x7f05dac9d000-0x7f05daca0000 0x7f05daca0000-0x7f05daca7000 /usr/lib64/libpthread-2.33.9000.so 0x7f05daca7000-0x7f05dacb6000 /usr/lib64/libpthread-2.33.9000.so 0x7f05dacb6000-0x7f05dacba000 /usr/lib64/libpthread-2.33.9000.so 0x7f05dacba000-0x7f05dacbb000 /usr/lib64/libpthread-2.33.9000.so 0x7f05dacbb000-0x7f05dacbc000 /usr/lib64/libpthread-2.33.9000.so 0x7f05dacbc000-0x7f05dacbd000 /usr/lib64/libpthread-2.33.9000.so 0x7f05dacbd000-0x7f05dacc1000 0x7f05dacc1000-0x7f05dacc4000 /usr/lib64/librt-2.33.9000.so 0x7f05dacc4000-0x7f05dacc8000 /usr/lib64/librt-2.33.9000.so 0x7f05dacc8000-0x7f05dacca000 /usr/lib64/librt-2.33.9000.so 0x7f05dacca000-0x7f05daccb000 /usr/lib64/librt-2.33.9000.so 0x7f05daccb000-0x7f05daccc000 /usr/lib64/librt-2.33.9000.so 0x7f05daccc000-0x7f05dacce000 /usr/lib64/libdl-2.33.9000.so 0x7f05dacce000-0x7f05dacd0000 /usr/lib64/libdl-2.33.9000.so 0x7f05dacd0000-0x7f05dacd1000 /usr/lib64/libdl-2.33.9000.so 0x7f05dacd1000-0x7f05dacd2000 /usr/lib64/libdl-2.33.9000.so 0x7f05dacd2000-0x7f05dacd3000 0x7f05dacd3000-0x7f05dacf9000 /usr/lib64/libc-2.33.9000.so 0x7f05dacf9000-0x7f05dae46000 /usr/lib64/libc-2.33.9000.so 0x7f05dae46000-0x7f05dae92000 /usr/lib64/libc-2.33.9000.so 0x7f05dae92000-0x7f05dae93000 /usr/lib64/libc-2.33.9000.so 0x7f05dae93000-0x7f05dae96000 /usr/lib64/libc-2.33.9000.so 0x7f05dae96000-0x7f05dae99000 /usr/lib64/libc-2.33.9000.so 0x7f05dae99000-0x7f05daea2000 0x7f05daea2000-0x7f05daec6000 /usr/lib64/libasan.so.6.0.0 0x7f05daec6000-0x7f05daf93000 /usr/lib64/libasan.so.6.0.0 0x7f05daf93000-0x7f05dafc6000 /usr/lib64/libasan.so.6.0.0 0x7f05dafc6000-0x7f05dafca000 /usr/lib64/libasan.so.6.0.0 0x7f05dafca000-0x7f05dafcd000 /usr/lib64/libasan.so.6.0.0 0x7f05dafcd000-0x7f05db875000 0x7f05db876000-0x7f05db87c000 0x7f05db87c000-0x7f05db87d000 /usr/lib64/ld-2.33.9000.so 0x7f05db87d000-0x7f05db8a1000 /usr/lib64/ld-2.33.9000.so 0x7f05db8a1000-0x7f05db8aa000 /usr/lib64/ld-2.33.9000.so 0x7f05db8aa000-0x7f05db8ac000 /usr/lib64/ld-2.33.9000.so 0x7f05db8ac000-0x7f05db8ae000 /usr/lib64/ld-2.33.9000.so 0x7ffed2dc5000-0x7ffed2de6000 [stack] 0x7ffed2dfb000-0x7ffed2dfe000 [vvar] 0x7ffed2dfe000-0x7ffed2e00000 [vdso] 0xffffffffff600000-0xffffffffff601000 [vsyscall] ==11818==End of process memory map. ==11818==AddressSanitizer CHECK failed: ../../../../libsanitizer/sanitizer_common/sanitizer_common.cpp:54 "((0 && "unable to mmap")) != (0)" (0x0, 0x0) <empty stack> Expected results: No errors Additional info: Initially I tested with different reproducer. Using LD_PRELOAD sh$ gcc -o test test.c sh$ LD_PRELOAD=`rpm -ql libasan | grep so | tail -n1` ./test But the result is the same