-
Notifications
You must be signed in to change notification settings - Fork 38.8k
doc: document workaround and fallback for macOS fuzzing #32084
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
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32084. ReviewsSee the guideline for information on the review process. |
It would be good to understand why it doesn't work anymore first. |
|
Thanks for the hint @brunoerg, I did a bisect to see if it's the commits or the update, which gave me contradictory results. ccache -C && git clean -fxd && git reset --hardGuess we can't rely on cache invalidation here. |
I'd appreciate it if you could provide steps to reproduce the scenario where Ccache cache causes a build issue. |
|
I can't, I deleted everything as the above steps show. |
I'm getting the same issue and it works when I explicity set e.g.: |
It's still not working for me in a few cases, no matter how many caches I delete or how much I go back in time. rm -rfd build_fuzz \
&& cmake --preset=libfuzzer \
-DCMAKE_C_COMPILER="$(brew --prefix llvm)/bin/clang" \
-DCMAKE_CXX_COMPILER="$(brew --prefix llvm)/bin/clang++" \
-DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld" \
&& cmake --build build_fuzz \
&& FUZZ=psbt_base64_decode build_fuzz/bin/fuzzwhich fails immediately with Which doesn't make sense since Similarly to #32089, |
|
I'll reopen since others seem to have a similar problem as well - once we figure out what's causing it exactly, we can go back to |
0bc12d1 to
3bef6c4
Compare
|
I am currently having similar problems (also on macos). I am not sure if I want to change the docs though, obviously it would be great if we could figure out the actual issue instead. Maybe a bit more context that I can add, I am seeing the same error as above when running without providing a corpus but with a corpus I see this: So there seems to be some problem with reading the corpus when trying to provide a corpus. |
|
@fjahr Did you try with |
I actually hadn't because for what I was working on I didn't need the sanitiziers so I went with nosan right away but I just tried it now and it does indeed fix it for me with this with or without corpus, e.g. this works: If that works for you as well @l0rinc maybe that's a better docs change to suggest trying that. |
|
DetailsASAN_OPTIONS=detect_container_overflow=0 FUZZ=psbt_base64_decode build_fuzz/bin/fuzzfuzz(61762,0x1fa5e4840) malloc: nano zone abandoned due to inability to reserve vm space.
INFO: Running with entropic power schedule (0xFF, 100).
INFO: Seed: 3061578036
INFO: Loaded 1 modules (1253375 inline 8-bit counters): 1253375 [0x106344000, 0x106475fff),
INFO: Loaded 1 PC tables (1253375 PCs): 1253375 [0x106476000,0x107795ff0),
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 4096 bytes
libc++abi: terminating due to uncaught exception of type std::__1::ios_base::failure: DataStream::read(): end of data: unspecified iostream_category error
==61762== ERROR: libFuzzer: deadly signal
#0 0x0001097fd248 in __sanitizer_print_stack_trace+0x28 (libclang_rt.asan_osx_dynamic.dylib:arm64+0x5d248)
#1 0x00010593be34 in fuzzer::PrintStackTrace()+0x2c (fuzz:arm64+0x1037a3e34)
#2 0x00010592f7e8 in fuzzer::Fuzzer::CrashCallback()+0x54 (fuzz:arm64+0x1037977e8)
#3 0x000190caade0 in _sigtramp+0x34 (libsystem_platform.dylib:arm64+0x3de0)
#4 0xd05c000190c73f6c (<unknown module>)
#5 0x1644800190b80904 (<unknown module>)
#6 0x9817000190c2a448 (<unknown module>)
#7 0xd109000190c18a20 (<unknown module>)
#8 0xe8378001908c13f0 (<unknown module>)
#9 0x2d14800190c2970c (<unknown module>)
#10 0x2d7a800190c2ccd8 (<unknown module>)
#11 0xe77800190c2cc80 (<unknown module>)
#12 0xed628001023bac20 (<unknown module>)
#13 0x000102568c84 in void PartiallySignedTransaction::Unserialize<DataStream>(DataStream&)+0x224 (fuzz:arm64+0x1003d0c84)
#14 0x000103186ad0 in DecodeRawPSBT(PartiallySignedTransaction&, std::__1::span<std::byte const, 18446744073709551615ul>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&)+0x200 (fuzz:arm64+0x100feead0)
#15 0x00010318645c in DecodeBase64PSBT(PartiallySignedTransaction&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&)+0x1dc (fuzz:arm64+0x100fee45c)
#16 0x0001021e7a68 in psbt_base64_decode_fuzz_target(std::__1::span<unsigned char const, 18446744073709551615ul>)+0x270 (fuzz:arm64+0x10004fa68)
#17 0x000102e524d8 in LLVMFuzzerTestOneInput+0x198 (fuzz:arm64+0x100cba4d8)
#18 0x000105930d94 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)+0x12c (fuzz:arm64+0x103798d94)
#19 0x000105931f04 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__1::vector<fuzzer::SizedFile, std::__1::allocator<fuzzer::SizedFile>>&)+0x220 (fuzz:arm64+0x103799f04)
#20 0x00010593258c in fuzzer::Fuzzer::Loop(std::__1::vector<fuzzer::SizedFile, std::__1::allocator<fuzzer::SizedFile>>&)+0x98 (fuzz:arm64+0x10379a58c)
#21 0x000105928f44 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long))+0x1dd0 (fuzz:arm64+0x103790f44)
#22 0x00010593c838 in main+0x24 (fuzz:arm64+0x1037a4838)
#23 0x0001908f4270 (<unknown module>)
#24 0xaa107ffffffffffc (<unknown module>)
NOTE: libFuzzer has rudimentary signal handlers.
Combine libFuzzer with AddressSanitizer or similar for better crash reports.
SUMMARY: libFuzzer: deadly signal
MS: 0 ; base unit: 0000000000000000000000000000000000000000
artifact_prefix='./'; Test unit written to ./crash-da39a3ee5e6b4b0d3255bfef95601890afd80709
Base64: But the |
3bef6c4 to
8b7c8a2
Compare
libfuzzer-nosan for macOS|
I think we have two different issues here: @l0rinc is getting "libc++abi: terminating due to uncaught exception of type std::__1::ios_base::failure: DataStream::read(): end of data: unspecified iostream_category error". Me and @fjahr were getting the |
Already pushed, please review the changes. |
|
Yeah, I do still get the error that @l0rinc sees when I test |
fjahr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments but I am still ~0 on this change and would much rather prefer that someone tries to spend more time on investigating the issue. I tried for a bit but wasn't successful so far.
|
If we're going to put |
8b7c8a2 to
89477d0
Compare
I've put this in the description already, but added it to the doc as well now |
I tend to agree. It would be good to check:
Unrelated to that, it would be good to minimize the |
Retried it with with latest Details
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
xcodebuild -runFirstLaunchdidn't help either. Is it working for anyone else? |
I've tried with this exact command and it compiled, but I got the following error: fuzz(27696,0x1e41a5c40) malloc: nano zone abandoned due to inability to reserve vm space.
INFO: Running with entropic power schedule (0xFF, 100).
INFO: Seed: 1403259666
INFO: Loaded 1 modules (1308295 inline 8-bit counters): 1308295 [0x1049ac000, 0x104aeb687),
INFO: Loaded 1 PC tables (1308295 PCs): 1308295 [0x104aeb688,0x105ee1ef8),
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 4096 bytes
libc++abi: terminating due to uncaught exception of type std::__1::ios_base::failure: DataStream::read(): end of data: unspecified iostream_category error
==27696== ERROR: libFuzzer: deadly signal
#0 0x0001079eacd4 in __sanitizer_print_stack_trace+0x28 (libclang_rt.asan_osx_dynamic.dylib:arm64+0x5ecd4)
#1 0x000103f695e4 in fuzzer::PrintStackTrace()+0x2c (fuzz:arm64+0x1039ad5e4)
#2 0x000103f5c8d0 in fuzzer::Fuzzer::CrashCallback()+0x54 (fuzz:arm64+0x1039a08d0)
#3 0x00018d909a20 in _sigtramp+0x34 (libsystem_platform.dylib:arm64+0x3a20)
#4 0xec7e80018d8d9cbc (<unknown module>)
#5 0xd05e80018d7e5a3c (<unknown module>)
#6 0x7d4b80018d89106c (<unknown module>)
#7 0xe06080018d88110c (<unknown module>)
#8 0x5e4180018d527998 (<unknown module>)
#9 0x210180018d890430 (<unknown module>)
#10 0xe33180018d89351c (<unknown module>)
#11 0xfb1200018d893460 (<unknown module>)
#12 0xc668001007dfa88 (<unknown module>)
#13 0x0001009a2d08 in void PartiallySignedTransaction::Unserialize<DataStream>(DataStream&)+0x228 (fuzz:arm64+0x1003e6d08)
#14 0x0001016603d0 in DecodeRawPSBT(PartiallySignedTransaction&, std::__1::span<std::byte const, 18446744073709551615ul>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&)+0x20c (fuzz:arm64+0x1010a43d0)
#15 0x00010165fd50 in DecodeBase64PSBT(PartiallySignedTransaction&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&)+0x1dc (fuzz:arm64+0x1010a3d50)
#16 0x00010060f190 in psbt_base64_decode_fuzz_target(std::__1::span<unsigned char const, 18446744073709551615ul>)+0x270 (fuzz:arm64+0x100053190)
#17 0x000101311890 in LLVMFuzzerTestOneInput+0x1bc (fuzz:arm64+0x100d55890)
#18 0x000103f5df64 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)+0x134 (fuzz:arm64+0x1039a1f64)
#19 0x000103f5f330 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__1::vector<fuzzer::SizedFile, std::__1::allocator<fuzzer::SizedFile>>&)+0x220 (fuzz:arm64+0x1039a3330)
#20 0x000103f5f9b4 in fuzzer::Fuzzer::Loop(std::__1::vector<fuzzer::SizedFile, std::__1::allocator<fuzzer::SizedFile>>&)+0x98 (fuzz:arm64+0x1039a39b4)
#21 0x000103f562b8 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long))+0x1ee8 (fuzz:arm64+0x10399a2b8)
#22 0x000103f69fe4 in main+0x24 (fuzz:arm64+0x1039adfe4)
#23 0x00018d5590dc (<unknown module>)
#24 0xd1437ffffffffffc (<unknown module>)Homebrew clang version 20.1.2
Target: arm64-apple-darwin23.3.0
Thread model: posix
InstalledDir: /opt/homebrew/Cellar/llvm/20.1.2/bin
Configuration file: /opt/homebrew/etc/clang/arm64-apple-darwin23.cfg |
89477d0 to
4a6a649
Compare
Added the links to the doc and added another workaround of setting the target architecture an Apple Silicon for errors like (see #32084 (comment) for details): usr/include/malloc/_malloc_type.h:66:126: error: unknown type name 'size_t'; did you mean 'std::size_t'? |
4a6a649 to
d01a1a9
Compare
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
d01a1a9 to
dc3a0d8
Compare
On macOS, running fuzz targets with the default `libfuzzer` preset can fail due to linker errors or AddressSanitizer or header incompatibility issues such as: * Linker did not accept requested flags, you are missing required libraries * ==54938==ERROR: AddressSanitizer: container-overflow on address 0x608000000ae8 at pc 0x000104518ef4 bp 0x00016b92e6f0 sp 0x00016b92e6e8 Documented a workaround using: * `ASAN_OPTIONS=detect_container_overflow=0` - see https://github.com/google/sanitizers/wiki/AddressSanitizerContainerOverflow#false-positives; * `target arm64-apple-macos11` - see https://developer.apple.com/documentation/apple-silicon/building-a-universal-macos-binary#Update-the-Architecture-List-of-Custom-Makefiles * `--preset=libfuzzer-nosan` - see https://github.com/bitcoin/bitcoin/blob/master/CMakePresets.json#L50-L60 Since `libfuzzer-nosan` builds to a different folder, I've added the full build steps after configuration. I've also deleted the `brew install llvm` duplication a few lines below, fixed a typo (`non-systems clang`), removed the trailing `$` in the Mac examples to make the code easily copyable (and since Macs don't usually have that in the console) and adjusted the fuzzer link for Mac in `Quickstart guide`. Co-authored-by: brunoerg <[email protected]> Co-authored-by: Fabian Jahr <[email protected]>
dc3a0d8 to
b9f54e1
Compare
|
For future me, wondering how to make fuzzing work on a Mac with latest Clang + AppleClang - this is the version that mostly works for me (though it fails in a lot of places where Linux doesn't): Example failure on masterand a nosan version: |
After the recent adjustment to fuzzing docs in #31954, most of the tests started working on macOS again.
A few of them are still failing for weird reasons, let's document how to work around those:
Since
libfuzzer-nosanbuilds to a different folder, I've added the full build steps after configuration.I've also deleted the
brew install llvmduplication, fixed a typo (non-systems clang), and adjusted the fuzzer link for mac inQuickstart guide