-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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
Failure to build with address sanitizer #80537
Comments
Trying to run make after './configure --with-address-sanitizer --with-pydebug' fails with leak of locale string |
just for me, btharper, which system do you use? because I have a fedora 29 and when I try to compile with these flags, getaddrinfo is not found. |
ok, found I have to disable ipv6 and install libasan ./python -E -S -m sysconfig --generate-posix-vars ;\ ================================================================= Direct leak of 34 byte(s) in 1 object(s) allocated from: Direct leak of 34 byte(s) in 1 object(s) allocated from: SUMMARY: AddressSanitizer: 68 byte(s) leaked in 2 allocation(s). |
your PR seems to be fine. but I continue to get two refleaks with valgrind but don't worry, @vstinner is working on these refleaks. ==5440== 64 bytes in 1 blocks are possibly lost in loss record 1 of 2 |
At least, "./python -V" no longer leaks at commit dcf6171. $ ./configure --with-valgrind
$ make
$ valgrind ./python -V
==9553== Memcheck, a memory error detector
==9553== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==9553== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info
==9553== Command: ./python -V
==9553==
Python 3.8.0a2+
==9553==
==9553== HEAP SUMMARY:
==9553== in use at exit: 0 bytes in 0 blocks
==9553== total heap usage: 33 allocs, 33 frees, 5,933 bytes allocated
==9553==
==9553== All heap blocks were freed -- no leaks are possible
==9553==
==9553== For counts of detected and suppressed errors, rerun with: -v
==9553== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) |
I'm on Ubuntu 18.10/amd64 compiling with Ubuntu's GCC 8.2.0, I know there's some libraries that are missing dependencies (including bz2 and sqlite) so I may have missed the ipv6 dependencies as well. My eventual goal was to be able to build a pgo optimized build of cpython with the address sanitizer turned on. Currently on my build of f5f336a I see 12 failing tests and a heap use after free as part of the ctypes test suite. The ctypes use after free has already been submitted as bpo-36253 since it was the only thing asan caught during tests with the leak sanitizer turned off. |
For what it's worth, with current HEAD of master (commit 62be338 which includes previously merged PRs from this issue), current macOS clang with address sanitizer and pydebug enabled gets an assertion failure in parsetok.c. Current HEAD of 3.7 does not. $ ./configure --with-address-sanitizer --prefix=/tmp/d --with-pydebu
$ make -j3
[...]
./python -E -S -m sysconfig --generate-posix-vars ;\
if test $? -ne 0 ; then \
echo "generate-posix-vars failed" ; \
rm -f ./pybuilddir.txt ; \
exit 1 ; \
fi
CC='gcc' LDSHARED='gcc -bundle -undefined dynamic_lookup -fsanitize=address ' OPT='-g -O0 -Wall' _TCLTK_INCLUDES='' _TCLTK_LIBS='' ./python -E ./setup.py build
Assertion failed: ((intptr_t)(int)(a - line_start) == (a - line_start)), function parsetok, file Parser/parsetok.c, line 308.
/bin/sh: line 1: 95059 Abort trap: 6 CC='gcc' LDSHARED='gcc -bundle -undefined dynamic_lookup -fsanitize=address ' OPT='-g -O0 -Wall' _TCLTK_INCLUDES='' _TCLTK_LIBS='' ./python -E ./setup.py $quiet build
make: *** [sharedmods] Error 134
$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
# same result with explicit CC=clang |
I'm not sure about the change from 3.7 to master, but that assertion may be more likely to happen while instrumented with ASAN due to the extra space reserved between heap objects. As far as I can tell it's just expecting that the offset of two pointers will fit within an int instead of a intptr_t (4 bytes versus 8 bytes on my system). For me running the test_pydoc from the test suite fails reliably with the parsetok.c assertion failure, but can be made to pass with a smaller ASAN redzone. The redzone must be a power of 2 and at least 16, default of 2048. Fails: Passes: Values of 16, 32, and 64 also pass. |
@ned, I have found a solution on Linux, will try on this evening with my |
See also bpo-36724 "Clear _PyRuntime at exit". |
The initial issue has been fixed, so I close the issue. I prefer to get more specific issues like bpo-36724 "Clear _PyRuntime at exit" to following changes. Thanks Ben Harper for the bug report and the fix. Note: Ben, I like your songs! Good to know that you chose to contribute to Python in your free time! ;-) |
Oh. test_daemon_threads_shutdown_stdout_deadlock of test_io fails randomly on buildbots. I ran "./python -m test test_io -m '*daemon*' -F -j4" for 5 minutes on my Fedora 29 before merging my PR, but I didn't get any failure :-( ====================================================================== Traceback (most recent call last):
File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel-z/build/Lib/test/test_io.py", line 4186, in test_daemon_threads_shutdown_stdout_deadlock
self.check_daemon_threads_shutdown_deadlock('stdout')
File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel-z/build/Lib/test/test_io.py", line 4177, in check_daemon_threads_shutdown_deadlock
self.assertIn("Fatal Python error: could not acquire lock "
AssertionError: "Fatal Python error: could not acquire lock for <_io.BufferedWriter name='<stdout>'> at interpreter shutdown, possibly due to daemon threads" not found in 'Fatal Python error: PyCOND_FINI(_PyRuntime.ceval.gil.cond) failed' Failures: AMD64 Fedora Rawhide Clang Installed 3.x: fail then pass s390x Debian 3.x: fail then pass s390x RHEL 3.x: fail twice AMD64 Debian root 3.x: fail twice |
I just reverted the change. I'm unable to reproduce and I am not available this week to investigate anyway. |
Can we close this issue, or is there a remaining known bug? |
FWIW, the assertion error on macOS reported above in msg338774 does not seem to occur anymore with current HEAD of master and with recent system clang (Apple clang version 11.0.0 (clang-1100.0.33.8)) on macOS 10.14.6. |
The default build of python with ASAN builds successfully. Test suite and PGO build are currently blocked, but that can be separated if it makes more sense to handle them individually. Would it make sense to add an ASAN build to the CI pipeline to make detection automatic going forward? |
Yeah, please open one issue per ASAN issue (try to group similar warnings in the same Python issue?).
Gregory maintains a clang UBSan buildbot: Usually I prefer to setup a buildbot when most issues are fixed. I close this issue. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: