-
Notifications
You must be signed in to change notification settings - Fork 37
test, ci: Fix threadsanitizer errors in mptest #222
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
Changes from 1 commit
7eb1da1
ca3c05d
c332774
b74e1bb
73d22ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| , enableLibcxx ? false # Whether to use libc++ toolchain and libraries instead of libstdc++ | ||
| , minimal ? false # Whether to create minimal shell without extra tools (faster when cross compiling) | ||
| , capnprotoVersion ? null | ||
| , capnprotoSanitizers ? null # Optional sanitizers to build cap'n proto with | ||
| , cmakeVersion ? null | ||
| , libcxxSanitizers ? null # Optional LLVM_USE_SANITIZER value to use for libc++, see https://llvm.org/docs/CMake.html | ||
| }: | ||
|
|
@@ -41,7 +42,17 @@ let | |
| } // (lib.optionalAttrs (lib.versionOlder capnprotoVersion "0.10") { | ||
| env = { }; # Drop -std=c++20 flag forced by nixpkgs | ||
| })); | ||
| capnproto = capnprotoBase.override (lib.optionalAttrs enableLibcxx { clangStdenv = llvm.libcxxStdenv; }); | ||
| capnproto = (capnprotoBase.overrideAttrs (old: lib.optionalAttrs (capnprotoSanitizers != null) { | ||
| env = (old.env or { }) // { | ||
| CXXFLAGS = | ||
| lib.concatStringsSep " " [ | ||
| (old.env.CXXFLAGS or "") | ||
| "-fsanitize=${capnprotoSanitizers}" | ||
| "-fno-omit-frame-pointer" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In b74e1bb ci: Use tsan-instrumented cap'n proto in sanitizers job: in Bitcoin Core
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes my understanding is it just helps provide better debug information in general, so maybe also be useful with GDB. This suggestion just came from chatgpt though, so it is good to know different sanitizer docs also recommend it. Thanks for the links!
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, this is one of the first things I do when debugging. Also necessary for anything that needs traces, like generating flamegraphs. It forces the compiler to use the frame-pointer register as-intended, rather than as a general purpose register. Abuse of that extra register is necessary in certain places (like our sha2 impl, IIRC), and useful in others to avoid stack spilling, but is generally just an optimization that's in conflict with debugging. |
||
| "-g" | ||
| ]; | ||
| }; | ||
| })).override (lib.optionalAttrs enableLibcxx { clangStdenv = llvm.libcxxStdenv; }); | ||
| clang = if enableLibcxx then llvm.libcxxClang else llvm.clang; | ||
| clang-tools = llvm.clang-tools.override { inherit enableLibcxx; }; | ||
| cmakeHashes = { | ||
|
|
||
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.
b74e1bb:
Adds
capnprotoSanitizersif specified. This apply the "Thread" sanitizer specified in sanitize.bash.The flags
-fno-omit-frame-pointerand-ghelp with producing better stack traces and showing file names and line numbers in warning messages. For example see https://clang.llvm.org/docs/ThreadSanitizer.html#usage