-
Notifications
You must be signed in to change notification settings - Fork 1.1k
ci: Use clang-snapshot in "MSan" job #1750
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
base: master
Are you sure you want to change the base?
Conversation
From https://github.com/bitcoin-core/secp256k1/actions/runs/17829295048/job/50691626826:
|
c7119a3
to
f2c48c7
Compare
Added a commit to silence the |
I think that's a Clang bug.
So yes, we're passing a const pointer to an uninitialized portion of memory, which is typically pointless: the callee can't read it (UB) and it is not allowed to write it either. But Are you willing to report this upstream? On our side, I think there are some nicer options:
I tend to 3. It's perhaps the most complex option, but also the most future-proof? |
I agree with your analysis. That's why I chose to suppress the warning rather than take another approach.
That was my initial approach, but I didn’t manage to implement it properly. Could you suggest your patch? |
Can you try this in #if defined(__has_feature)
# if __has_feature(memory_sanitizer)
# include <sanitizer/msan_interface.h>
# define SECP256K1_CHECKMEM_ENABLED 1
# if defined(__clang__)
# define SECP256K1_CHECKMEM_UNDEFINE(p, len) do { \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wuninitialized-const-pointer\"") \
__msan_allocated_memory((p), (len)); \
_Pragma("clang diagnostic pop") \
} while(0)
# else
# define SECP256K1_CHECKMEM_UNDEFINE(p, len) __msan_allocated_memory((p), (len))
# endif
# define SECP256K1_CHECKMEM_DEFINE(p, len) __msan_unpoison((p), (len))
# define SECP256K1_CHECKMEM_MSAN_DEFINE(p, len) __msan_unpoison((p), (len))
# define SECP256K1_CHECKMEM_CHECK(p, len) __msan_check_mem_is_initialized((p), (len))
# define SECP256K1_CHECKMEM_RUNNING() (1)
# endif
#endif
Would you be willing to report it upstream? Perhaps it will be fixed before the release of clang 21 and then we'll be able to drop this workaround. |
Thanks! Taken. UPD.
https://github.com/llvm/llvm-project/releases/tag/llvmorg-21.1.1 |
f2c48c7
to
d6832a1
Compare
The feedback from @real-or-random has been addressed. |
Indeed. If I read correctly, clang has always supported it. https://clang.llvm.org/c_status.html |
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.
utACK mod nit
# define SECP256K1_CHECKMEM_UNDEFINE(p, len) __msan_allocated_memory((p), (len)) | ||
# if defined(__clang__) | ||
# define SECP256K1_CHECKMEM_UNDEFINE(p, len) do { \ | ||
_Pragma("clang diagnostic push") \ |
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.
_Pragma("clang diagnostic push") \ | |
# Work around https://github.com/llvm/llvm-project/issues/160094 | |
_Pragma("clang diagnostic push") \ |
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.
Thanks! Done.
Co-authored-by: Tim Ruffing <me@real-or-random.org>
d6832a1
to
7ca890d
Compare
In Bitcoin Core, the "MSan" CI jobs use the latest tagged Clang available from http://apt.llvm.org.
This PR applies similar changes and switches the "MSan" CI jobs to clang-snapshot.
This exposes problematic code that was reported in bitcoin/bitcoin#33284.