Skip to content

Commit a44a339

Browse files
Merge #1750: ci: Use clang-snapshot in "MSan" job
53585f9 ci: Use clang-snapshot in "MSan" job (Hennadii Stepanov) 6894c96 Fix Clang 21+ `-Wuninitialized-const-pointer` warning when using MSan (Hennadii Stepanov) Pull request description: 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. ACKs for top commit: real-or-random: utACK 53585f9 Tree-SHA512: 79bc10f1d0a60ed67b518eb8fab9a48146a4ef1fff95c8775717be3a950b323ae89a12999504ed8446f164da426894abe02f9fb61b5ca19453d549a34873b73b
2 parents 2b7337f + 53585f9 commit a44a339

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,9 @@ jobs:
417417
# when ctime_tests when enabled.
418418
CFLAGS: '-fsanitize=memory -fsanitize-recover=memory -fsanitize-memory-param-retval -g'
419419
CTIMETESTS: 'no'
420+
cc:
421+
- 'clang'
422+
- 'clang-snapshot'
420423

421424
env:
422425
ECDH: 'yes'
@@ -425,7 +428,7 @@ jobs:
425428
SCHNORRSIG: 'yes'
426429
MUSIG: 'yes'
427430
ELLSWIFT: 'yes'
428-
CC: 'clang'
431+
CC: ${{ matrix.cc }}
429432
SECP256K1_TEST_ITERS: 32
430433
ASM: 'no'
431434
WITH_VALGRIND: 'no'

ci/linux-debian.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ RUN \
7171
# Determine the version number of the LLVM development branch
7272
LLVM_VERSION=$(apt-cache search --names-only '^clang-[0-9]+$' | sort -V | tail -1 | cut -f1 -d" " | cut -f2 -d"-" ) && \
7373
# Install
74-
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y "clang-${LLVM_VERSION}" && \
74+
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y "clang-${LLVM_VERSION}" "libclang-rt-${LLVM_VERSION}-dev" && \
7575
# Create symlink
7676
ln -s "/usr/bin/clang-${LLVM_VERSION}" /usr/bin/clang-snapshot && \
7777
# Clean up

src/checkmem.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,17 @@
4848
# if __has_feature(memory_sanitizer)
4949
# include <sanitizer/msan_interface.h>
5050
# define SECP256K1_CHECKMEM_ENABLED 1
51-
# define SECP256K1_CHECKMEM_UNDEFINE(p, len) __msan_allocated_memory((p), (len))
51+
# if defined(__clang__) && ((__clang_major__ == 21 && __clang_minor__ >= 1) || __clang_major__ >= 22)
52+
# define SECP256K1_CHECKMEM_UNDEFINE(p, len) do { \
53+
/* Work around https://github.com/llvm/llvm-project/issues/160094 */ \
54+
_Pragma("clang diagnostic push") \
55+
_Pragma("clang diagnostic ignored \"-Wuninitialized-const-pointer\"") \
56+
__msan_allocated_memory((p), (len)); \
57+
_Pragma("clang diagnostic pop") \
58+
} while(0)
59+
# else
60+
# define SECP256K1_CHECKMEM_UNDEFINE(p, len) __msan_allocated_memory((p), (len))
61+
# endif
5262
# define SECP256K1_CHECKMEM_DEFINE(p, len) __msan_unpoison((p), (len))
5363
# define SECP256K1_CHECKMEM_MSAN_DEFINE(p, len) __msan_unpoison((p), (len))
5464
# define SECP256K1_CHECKMEM_CHECK(p, len) __msan_check_mem_is_initialized((p), (len))

0 commit comments

Comments
 (0)