Skip to content

Commit 7ee34b6

Browse files
authored
gh-450: Workaround for failing ASAN on macOS (#451)
1 parent 8906549 commit 7ee34b6

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

master/custom/builders.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
UnixRefleakBuild,
1414
UnixNoGilBuild,
1515
UnixNoGilRefleakBuild,
16-
UnixAsanNoGilBuild,
16+
MacOSAsanNoGilBuild,
1717
AIXBuild,
1818
AIXBuildWithXLC,
1919
PGOUnixBuild,
@@ -223,7 +223,7 @@
223223
("AMD64 Windows Server 2022 NoGIL", "itamaro-win64-srv-22-aws", Windows64NoGilBuild),
224224

225225
# macOS x86-64 clang
226-
("x86-64 MacOS Intel ASAN NoGIL", "itamaro-macos-intel-aws", UnixAsanNoGilBuild),
226+
("x86-64 MacOS Intel ASAN NoGIL", "itamaro-macos-intel-aws", MacOSAsanNoGilBuild),
227227
]
228228

229229

master/custom/factories.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,31 @@ class MacOSArmWithBrewNoGilRefleakBuild(UnixNoGilRefleakBuild):
529529
"LDFLAGS=-L/opt/homebrew/lib",
530530
]
531531

532+
533+
class MacOSAsanNoGilBuild(UnixAsanNoGilBuild):
534+
buildersuffix = ".macos-with-brew.asan.nogil"
535+
configureFlags = UnixAsanNoGilBuild.configureFlags + [
536+
"--with-openssl=/opt/homebrew/opt/openssl@3",
537+
"CPPFLAGS=-I/opt/homebrew/include",
538+
"LDFLAGS=-L/opt/homebrew/lib",
539+
]
540+
asan_options = 'detect_leaks=0:allocator_may_return_null=1:handle_segv=0'
541+
compile_environ = {'ASAN_OPTIONS': asan_options}
542+
test_environ = {
543+
'ASAN_OPTIONS': asan_options,
544+
# Note: Need to set `MallocNanoZone=0` environment variable to workaround a macOS issue.
545+
# This was needed to workaround an issue with this builder that manifested as failures in 3 tests:
546+
# test_cmd_line, test_posix, test_subprocess
547+
# These failures seem to be related to the occurrence of this warning:
548+
# python.exe(74602,0x7ff84626a700) malloc: nano zone abandoned due to inability to reserve vm space.
549+
# It is unclear why (or if) it's *directly* causing the test failures, but setting `MallocNanoZone=0`
550+
# disables this optimization (and fixes the tests), which appears to be interfering with ASAN. See also:
551+
# https://stackoverflow.com/questions/64126942/malloc-nano-zone-abandoned-due-to-inability-to-preallocate-reserved-vm-space
552+
# https://github.com/python/buildmaster-config/issues/450 (and attached PR)
553+
'MallocNanoZone': '0',
554+
}
555+
556+
532557
##############################################################################
533558
############################ WINDOWS BUILDS ################################
534559
##############################################################################

0 commit comments

Comments
 (0)