llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.91k stars 11.52k forks source link

`SanitizerCommon-lsan-x86_64-Darwin :: Darwin/malloc_zone.cpp` fails on macOS 14 #87483

Open zmodem opened 5 months ago

zmodem commented 5 months ago

The test started failing in our build environment after it moved from macOS 13.5.2 to 14.4.1:

FAIL: SanitizerCommon-lsan-x86_64-Darwin :: Darwin/malloc_zone.cpp (73456 of 77879)
 ******************** TEST 'SanitizerCommon-lsan-x86_64-Darwin :: Darwin/malloc_zone.cpp' FAILED ********************
 Exit Code: 2

 Command Output (stderr):
 --
 RUN: at line 10: echo "leak:create_and_insert_msl_lite_zone" >> lsan.supp
 + echo leak:create_and_insert_msl_lite_zone
 RUN: at line 12: /Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/./bin/clang  --driver-mode=g++ -gline-tables-only -fsanitize=leak  -arch x86_64 -stdlib=libc++ -mmacosx-version-min=10.12 -isysroot /Volumes/Work/s/w/ir/cache/osx_sdk/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -mlinker-version=820.1  -I/Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/test -g /Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/test/sanitizer_common/TestCases/Darwin/malloc_zone.cpp -o /Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/lsan-x86_64-Darwin/Darwin/Output/malloc_zone.cpp.tmp
 + /Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/./bin/clang --driver-mode=g++ -gline-tables-only -fsanitize=leak -arch x86_64 -stdlib=libc++ -mmacosx-version-min=10.12 -isysroot /Volumes/Work/s/w/ir/cache/osx_sdk/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -mlinker-version=820.1 -I/Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/test -g /Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/test/sanitizer_common/TestCases/Darwin/malloc_zone.cpp -o /Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/lsan-x86_64-Darwin/Darwin/Output/malloc_zone.cpp.tmp
 RUN: at line 13: /Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/lsan-x86_64-Darwin/Darwin/Output/malloc_zone.cpp.tmp | FileCheck /Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/test/sanitizer_common/TestCases/Darwin/malloc_zone.cpp
 + /Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/lsan-x86_64-Darwin/Darwin/Output/malloc_zone.cpp.tmp
 + FileCheck /Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/test/sanitizer_common/TestCases/Darwin/malloc_zone.cpp
 RUN: at line 14: env MallocStackLogging=lite LSAN_OPTIONS=suppressions=lsan.supp   /Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/lsan-x86_64-Darwin/Darwin/Output/malloc_zone.cpp.tmp | FileCheck /Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/test/sanitizer_common/TestCases/Darwin/malloc_zone.cpp
 + env MallocStackLogging=lite LSAN_OPTIONS=suppressions=lsan.supp /Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/lsan-x86_64-Darwin/Darwin/Output/malloc_zone.cpp.tmp
 + FileCheck /Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/test/sanitizer_common/TestCases/Darwin/malloc_zone.cpp
 LeakSanitizer: bad pointer 0x7ff91c394221
 LeakSanitizer: CHECK failed: sanitizer_allocator_secondary.h:177 "((IsAligned(reinterpret_cast<uptr>(p), page_size_))) != (0)" (0x0, 0x0) (tid=2014389)
 FileCheck error: '<stdin>' is empty.
 FileCheck command line:  FileCheck /Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/test/sanitizer_common/TestCases/Darwin/malloc_zone.cpp

 --

 ********************

We didn't see any relevant LLVM changes around the time when the failure started, so it seems related to the OS version.

(See also https://crbug.com/332589870)

zmodem commented 5 months ago

@yln I think you added the test in 5ef4b190d9910fa6bfbd7406ea6629b53e4e8d79 Do you have any idea what might be happening?

yln commented 3 months ago

Hi @zmodem, I just ran this test locally on the latest macOS 14 and it seems to work for all the different sanitizers, including LSan.

Unfortunately, we don't have much information to go on:

env MallocStackLogging=lite LSAN_OPTIONS=suppressions=lsan.supp [...]/lsan-x86_64-Darwin/Darwin/Output/malloc_zone.cpp.tmp

LeakSanitizer: bad pointer 0x7ff91c394221
LeakSanitizer: CHECK failed: sanitizer_allocator_secondary.h:177 "((IsAligned(reinterpret_cast<uptr>(p), page_size_))) != (0)" (0x0, 0x0) (tid=2014389)

Can you get a debugging session on the system where it fails?