bpo-34602: Quadruple stack size on macOS when compiling with UBSAN#27309
bpo-34602: Quadruple stack size on macOS when compiling with UBSAN#27309ambv merged 4 commits intopython:mainfrom
Conversation
|
Ideally we could only quadruple the stack size if |
ammaraskar
left a comment
There was a problem hiding this comment.
Ideally we could only quadruple the stack size if
--with-undefined-behavior-sanitizeris used but I'm not sure how to do that.
I think you should just be able to do a conditional where LINKFORSHARED is set with
if test "$with_undefined_behavior_sanitizer" != "no"; then
|
Closed by mistake. I intend to add the quadrupling to pydebug builds only. |
|
It works now only when With: Without: Also, as @ammaraskar pointed out, this should be in sync with THREAD_STACK_SIZE so now it is. |
9f21de0 to
5d734c3
Compare
|
I rebased on current To demonstrate why this is necessary: Without this patch the test suite fails miserably with UBSANThere's plenty of clear stack issues like: (click to expand) Fatal Python error: AbortedCurrent thread 0x000000010db75dc0 (most recent call first): File "/Volumes/RAMDisk/cpy2/Lib/test/libregrtest/setup.py", line 82 in _test_audit_hook File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ File "/Volumes/RAMDisk/cpy2/Lib/xml/etree/ElementTree.py", line 178 in __repr__ ... With the patch tests almost passThe threading failure is another thing we'll have to get to work for UBSAN on macOS but it's unrelated to this bug. |
ronaldoussoren
left a comment
There was a problem hiding this comment.
The patch looks good in general, as mentioned below I'd use AC_DEFINE_UNQUOTED(THREAD_STACK_SIZE, ...) even if non using sanitisers and remove setting THREAD_STACK_SIZE for macOS from thread_pthread.h.
|
When you're done making the requested changes, leave the comment: |
|
I have made the requested changes; please review again. Using >>> import sysconfig
>>> sysconfig.get_config_var('LINKFORSHARED')
'-Wl,-stack_size,4000000 -framework CoreFoundation'
>>> sysconfig.get_config_var('THREAD_STACK_SIZE')
'0x4000000'No >>> import sysconfig
>>> sysconfig.get_config_var('LINKFORSHARED')
'-Wl,-stack_size,1000000 -framework CoreFoundation'
>>> sysconfig.get_config_var('THREAD_STACK_SIZE')
'0x1000000' |
|
Thanks for making the requested changes! @ronaldoussoren: please review the changes made to this pull request. |
|
Merging this since I have some UBSAN-related work for next week. |
|
Thanks @ambv for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10. |
|
Sorry, @ambv, I could not cleanly backport this to |
|
I'll deal with the conflict today. |
|
The conflict is because the 3.10 branch used autoconf 2.71 for its configure file whereas main (like the other branches) uses 2.69. |
…BSAN (pythonGH-27309) (cherry picked from commit be9de87) Co-authored-by: Łukasz Langa <lukasz@langa.pl>
|
GH-28280 is a backport of this pull request to the 3.10 branch. |
When running
./configurewith--with-undefined-behavior-sanitizer, the currently used stack size on macOS is insufficient to pass the test suite.https://bugs.python.org/issue34602