From 7ee34b6e27a1c255f8244f1020528c8e5f476783 Mon Sep 17 00:00:00 2001 From: Itamar Oren Date: Tue, 23 Jan 2024 10:08:17 -0800 Subject: [PATCH] gh-450: Workaround for failing ASAN on macOS (#451) --- master/custom/builders.py | 4 ++-- master/custom/factories.py | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/master/custom/builders.py b/master/custom/builders.py index ab3409883..b0216ab1f 100644 --- a/master/custom/builders.py +++ b/master/custom/builders.py @@ -13,7 +13,7 @@ UnixRefleakBuild, UnixNoGilBuild, UnixNoGilRefleakBuild, - UnixAsanNoGilBuild, + MacOSAsanNoGilBuild, AIXBuild, AIXBuildWithXLC, PGOUnixBuild, @@ -223,7 +223,7 @@ ("AMD64 Windows Server 2022 NoGIL", "itamaro-win64-srv-22-aws", Windows64NoGilBuild), # macOS x86-64 clang - ("x86-64 MacOS Intel ASAN NoGIL", "itamaro-macos-intel-aws", UnixAsanNoGilBuild), + ("x86-64 MacOS Intel ASAN NoGIL", "itamaro-macos-intel-aws", MacOSAsanNoGilBuild), ] diff --git a/master/custom/factories.py b/master/custom/factories.py index ea131a97c..055ac96a4 100644 --- a/master/custom/factories.py +++ b/master/custom/factories.py @@ -529,6 +529,31 @@ class MacOSArmWithBrewNoGilRefleakBuild(UnixNoGilRefleakBuild): "LDFLAGS=-L/opt/homebrew/lib", ] + +class MacOSAsanNoGilBuild(UnixAsanNoGilBuild): + buildersuffix = ".macos-with-brew.asan.nogil" + configureFlags = UnixAsanNoGilBuild.configureFlags + [ + "--with-openssl=/opt/homebrew/opt/openssl@3", + "CPPFLAGS=-I/opt/homebrew/include", + "LDFLAGS=-L/opt/homebrew/lib", + ] + asan_options = 'detect_leaks=0:allocator_may_return_null=1:handle_segv=0' + compile_environ = {'ASAN_OPTIONS': asan_options} + test_environ = { + 'ASAN_OPTIONS': asan_options, + # Note: Need to set `MallocNanoZone=0` environment variable to workaround a macOS issue. + # This was needed to workaround an issue with this builder that manifested as failures in 3 tests: + # test_cmd_line, test_posix, test_subprocess + # These failures seem to be related to the occurrence of this warning: + # python.exe(74602,0x7ff84626a700) malloc: nano zone abandoned due to inability to reserve vm space. + # It is unclear why (or if) it's *directly* causing the test failures, but setting `MallocNanoZone=0` + # disables this optimization (and fixes the tests), which appears to be interfering with ASAN. See also: + # https://stackoverflow.com/questions/64126942/malloc-nano-zone-abandoned-due-to-inability-to-preallocate-reserved-vm-space + # https://github.com/python/buildmaster-config/issues/450 (and attached PR) + 'MallocNanoZone': '0', + } + + ############################################################################## ############################ WINDOWS BUILDS ################################ ##############################################################################