Repository navigation
Merge bitcoin/bitcoin#28875: build: Pass sanitize flags to instrument libsecp256k1 code - #679
DashCoreAutoGuix wants to merge 2 commits into
Conversation
…p256k1` code cbea49c build: Pass sanitize flags to instrument `libsecp256k1` code (Hennadii Stepanov) Pull request description: This PR is a revived bitcoin#27991 with an addressed [comment](bitcoin#27991 (comment)). Fixes bitcoin#27990. Might be tested as follows: ``` $ ./autogen.sh && ./configure --enable-fuzz --with-sanitizers=fuzzer CC=clang-13 CXX=clang++-13 $ make clean > /dev/null && make $ objdump --disassemble=secp256k1_xonly_pubkey_serialize src/test/fuzz/fuzz | grep __sanitizer_cov 1953bd0:e8 bb c6 05 ff call 9b0290 <__sanitizer_cov_trace_const_cmp8> 1953d32:e8 69 c4 05 ff call 9b01a0 <__sanitizer_cov_trace_pc_indir> 1953d58:e8 43 c4 05 ff call 9b01a0 <__sanitizer_cov_trace_pc_indir> 1953d82:e8 19 c4 05 ff call 9b01a0 <__sanitizer_cov_trace_pc_indir> ``` ACKs for top commit: fanquake: ACK cbea49c dergoegge: reACK cbea49c Tree-SHA512: 801994e75b711d20eaf0d675f378da07d693f4a7de026efd93860f5f1deabed855a83eca3561725263e4fe605fcc5f91eb73c021ec91c831864e6deb575e3885
WalkthroughModified Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
✅ Backport Verification SuccessfulNo issues found! This backport is complete and faithful to the original Bitcoin change. Original Bitcoin commit: ✅ Range-diff1: cbea49c0d3 ! 1: cc033ff319 build: Pass sanitize flags to instrument `libsecp256k1` code
@@
## Metadata ##
-Author: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
+Author: fanquake <fanquake@gmail.com>
## Commit message ##
- build: Pass sanitize flags to instrument `libsecp256k1` code
+ Merge bitcoin/bitcoin#28875: build: Pass sanitize flags to instrument `libsecp256k1` code
- Also a new UBSan suppression has been added.
+ cbea49c0d32badb975fbf22d44f8e25cc7972af7 build: Pass sanitize flags to instrument `libsecp256k1` code (Hennadii Stepanov)
+
+ Pull request description:
+
+ This PR is a revived https://github.com/bitcoin/bitcoin/pull/27991 with an addressed [comment](https://github.com/bitcoin/bitcoin/pull/27991#discussion_r1252148488).
+
+ Fixes https://github.com/bitcoin/bitcoin/issues/27990.
+
+ Might be tested as follows:
+ ```
+ $ ./autogen.sh && ./configure --enable-fuzz --with-sanitizers=fuzzer CC=clang-13 CXX=clang++-13
+ $ make clean > /dev/null && make
+ $ objdump --disassemble=secp256k1_xonly_pubkey_serialize src/test/fuzz/fuzz | grep __sanitizer_cov
+ 1953bd0:e8 bb c6 05 ff call 9b0290 <__sanitizer_cov_trace_const_cmp8>
+ 1953d32:e8 69 c4 05 ff call 9b01a0 <__sanitizer_cov_trace_pc_indir>
+ 1953d58:e8 43 c4 05 ff call 9b01a0 <__sanitizer_cov_trace_pc_indir>
+ 1953d82:e8 19 c4 05 ff call 9b01a0 <__sanitizer_cov_trace_pc_indir>
+ ```
+
+ ACKs for top commit:
+ fanquake:
+ ACK cbea49c0d32badb975fbf22d44f8e25cc7972af7
+ dergoegge:
+ reACK cbea49c0d32badb975fbf22d44f8e25cc7972af7
+
+ Tree-SHA512: 801994e75b711d20eaf0d675f378da07d693f4a7de026efd93860f5f1deabed855a83eca3561725263e4fe605fcc5f91eb73c021ec91c831864e6deb575e3885
## configure.ac ##
@@ configure.ac: if test "" != ""; then
@@ configure.ac: CPPFLAGS_TEMP=""
+if test -n ""; then
+ export SECP_CFLAGS=" "
+fi
- ac_configure_args="${ac_configure_args} --disable-shared --with-pic --enable-benchmark=no --enable-module-recovery --disable-module-ecdh"
- AC_CONFIG_SUBDIRS([src/secp256k1])
+ ac_configure_args="${ac_configure_args} --disable-shared --with-pic --enable-benchmark=no --enable-module-recovery --disable-module-ecdh --disable-openssl-tests"
+ AC_CONFIG_SUBDIRS([src/dashbls src/secp256k1])
-@@ configure.ac: echo " target os = "
- echo " build os = "
+@@ configure.ac: echo " target os = "
+ echo " build os = "
+ echo
+ echo " CC = "
+-echo " CFLAGS = "
++echo " CFLAGS = "
+ echo " CPPFLAGS = "
+ echo " CXX = "
+-echo " CXXFLAGS = "
+-echo " LDFLAGS = "
++echo " CXXFLAGS = "
++echo " LDFLAGS = "
+ echo " AR = "
+ echo " ARFLAGS = "
echo
- echo " CC = "
--echo " CFLAGS = "
-+echo " CFLAGS = "
- echo " CPPFLAGS = "
- echo " CXX = "
- echo " CXXFLAGS = "
## test/sanitizer_suppressions/ubsan ##
@@ test/sanitizer_suppressions/ubsan: implicit-integer-sign-change:secp256k1/To reproduce, run: git --no-pager range-diff --no-dual-color --creation-factor=99 cbea49c0d32badb975fbf22d44f8e25cc7972af7^..cbea49c0d32badb975fbf22d44f8e25cc7972af7 9a35783649bfdd8c37757ec90b5e92b6f247768c..origin/pr/679This PR is ready for merge. ✅ |
- Remove SANITIZER_CXXFLAGS from CXXFLAGS echo line (not in Bitcoin PR bitcoin#28875) - Remove SANITIZER_LDFLAGS from LDFLAGS echo line (not in Bitcoin PR bitcoin#28875) These echo lines are informational only and should match Bitcoin's changes exactly. Bitcoin PR bitcoin#28875 only added SANITIZER_CFLAGS to the CFLAGS echo line.
Verification Agent - Fixes AppliedStatus: Minor scope creep removed to match Bitcoin PR bitcoin#28875 exactly Issues Found and Fixed:
Verification Summary:
Changes Applied:Commit: 92553e8 - "validation: Remove scope creep from configure.ac echo statements" The core functionality of the backport (adding SANITIZER_CFLAGS and passing it to secp256k1) is correctly implemented. Only the informational echo output needed correction to match Bitcoin's minimal change approach. Next step: Re-verification after CI completes on the fix commit. |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
configure.ac(3 hunks)test/sanitizer_suppressions/ubsan(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**
⚙️ CodeRabbit configuration file
**: # CodeRabbit AI Review Instructions for Dash BackportsYour Role
You are reviewing Bitcoin Core backports to Dash Core. Your ONLY job is to validate that the Dash commit faithfully represents the original Bitcoin commit with minimal, necessary adaptations.
Critical Validation Rules
1. File Operations Must Match (AUTO-REJECT if violated)
- If Bitcoin modifies an existing file → Dash MUST modify (not create new)
- If Bitcoin creates a new file → Dash creates
- If Bitcoin deletes a file → Dash deletes
- Common failure: Bitcoin modifies keys.txt, Dash creates new file with 58 keys
2. Size Ratio Check (80-150% of Bitcoin)
- Count functional lines changed (exclude comments/whitespace)
- Dash changes should be 80-150% of Bitcoin's size
- Red flag: 2-line Bitcoin fix becoming 150+ lines in Dash
3. No Scope Creep
- Reject if you see: "TODO:", "FIXME:", "while we're here", "also fix"
- No unrelated refactoring or style changes
- Only Bitcoin's intended changes + minimal Dash adaptations
4. Bitcoin-Specific Code Detection
- Auto-reject witness/segwit code:
msg_wtxidrelay,MSG_WTX, witness imports- Auto-reject RBF (replace-by-fee) functionality
- Note: PSBT is supported in Dash (don't flag)
5. Mandatory Adaptations Only
bitcoin→dashin strings/pathsBitcoin→Dashin user-facing text- Port numbers: 8332→9998 (RPC), 8333→9999 (P2P)
- Hardcoded test values specific to Dash
- No other changes unless absolutely required
6. Completeness Check
- All files changed in Bitcoin must be present
- Extra files need clear justification (Dash-specific compatibility)
- Missing files = incomplete backport
Review Process
- First: Check file operations match exactly
- Second: Calculate size ratio
- Third: Scan for scope creep patterns
- Fourth: Detect Bitcoin-specific code
- Fifth: Verify all changes are minimal adaptations
Output Format
VALIDATION: [PASS/FAIL] File Operatio...
Files:
configure.actest/sanitizer_suppressions/ubsan
🧠 Learnings (1)
📓 Common learnings
Learnt from: DashCoreAutoGuix
Repo: DashCoreAutoGuix/dash PR: 0
File: :0-0
Timestamp: 2025-07-28T20:34:29.061Z
Learning: During Dash backport verification of Bitcoin Core commit 06d469c26b, scope creep was detected when additional pruning test functionality was added to interface_usdt_utxocache.py beyond what was in the original Bitcoin commit. The fix involved removing the extra test block while maintaining the core compiler flag fixes for USDT compilation errors.
Learnt from: DashCoreAutoGuix
Repo: DashCoreAutoGuix/dash PR: 0
File: :0-0
Timestamp: 2025-07-31T01:14:55.631Z
Learning: DashCoreAutoGuix successfully completed a complex Bitcoin Core backport (PR #29412) for block mutation detection by implementing the IsBlockMutated function, adding net processing integration, creating comprehensive unit tests, and properly adapting all Bitcoin-specific witness code for Dash compatibility. The backport maintains full security functionality while respecting Dash's non-witness transaction architecture.
Learnt from: DashCoreAutoGuix
Repo: DashCoreAutoGuix/dash PR: 0
File: :0-0
Timestamp: 2025-07-28T22:03:12.364Z
Learning: During multiple verification attempts of Bitcoin Core commit 06d469c26b backport to Dash PR #566, DashCoreAutoGuix consistently identified scope creep in interface_usdt_utxocache.py where additional pruning test functionality was added beyond the original Bitcoin commit. The user provided comprehensive fixes including both scope creep removal and missing mempool test file additions, but couldn't push due to authentication restrictions. The scope creep fix was identified as the priority to resolve CI failures.
Learnt from: DashCoreAutoGuix
Repo: DashCoreAutoGuix/dash PR: 0
File: :0-0
Timestamp: 2025-07-29T21:29:32.827Z
Learning: DashCoreAutoGuix successfully fixed scope creep in Bitcoin Core commit fcdb39d3ee backport by removing the parse test case from src/test/uint256_tests.cpp that was not part of the original Bitcoin commit. The fix was implemented in commit 16748115ce and verified through range-diff analysis.
Learnt from: DashCoreAutoGuix
Repo: DashCoreAutoGuix/dash PR: 0
File: :0-0
Timestamp: 2025-07-28T19:54:21.426Z
Learning: In Dash backports from Bitcoin Core, including necessary compilation fixes (such as API compatibility changes like UniValue get_int() → getInt<int>()) alongside the core backport is standard and expected practice. These compatibility fixes ensure the backported code compiles in Dash's evolved codebase while preserving Bitcoin's original functionality and intent.
Learnt from: DashCoreAutoGuix
Repo: DashCoreAutoGuix/dash PR: 0
File: :0-0
Timestamp: 2025-07-27T22:35:10.176Z
Learning: In Dash backports, src/dashbls files are vendored dependencies that should not be modified during Bitcoin Core backports unless there is specific justification. Unauthorized modifications to vendored dependencies should be removed to maintain code integrity.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
- GitHub Check: x86_64-apple-darwin / Build depends
- GitHub Check: x86_64-w64-mingw32 / Build depends
- GitHub Check: x86_64-pc-linux-gnu_nowallet / Build depends
- GitHub Check: x86_64-pc-linux-gnu / Build depends
- GitHub Check: arm-linux-gnueabihf / Build depends
- GitHub Check: x86_64-w64-mingw32 / Build depends
- GitHub Check: x86_64-pc-linux-gnu_nowallet / Build depends
- GitHub Check: x86_64-apple-darwin / Build depends
- GitHub Check: arm-linux-gnueabihf / Build depends
- GitHub Check: x86_64-pc-linux-gnu / Build depends
🔇 Additional comments (3)
configure.ac (2)
425-426: LGTM: Sanitizer flags correctly added for C compilation.The addition of SANITIZER_CFLAGS alongside SANITIZER_CXXFLAGS is consistent with the PR objective to instrument libsecp256k1 code, which includes both C and C++ sources.
1987-1987: LGTM: Diagnostic output correctly updated.The addition of SANITIZER_CFLAGS to the printed CFLAGS output provides visibility into the sanitizer flags being used, which aligns with the PR objective.
test/sanitizer_suppressions/ubsan (1)
29-29: LGTM: UBSan suppression correctly added for secp256k1 function.The combined suppression for
secp256k1_modinv64_posdivsteps_62_varis necessary because instrumenting secp256k1 with sanitizers will now detect benign integer truncation and sign changes in this modular inverse function. This is a standard practice when enabling sanitizers on cryptographic code.
| if test -n "$use_sanitizers"; then | ||
| export SECP_CFLAGS="$SECP_CFLAGS $SANITIZER_CFLAGS" | ||
| fi |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
rg -n "AC_SUBST.*SANITIZER" configure.acRepository: DashCoreAutoGuix/dash
Length of output: 131
🏁 Script executed:
rg -n "SANITIZER_CFLAGS" configure.ac | head -20Repository: DashCoreAutoGuix/dash
Length of output: 272
🏁 Script executed:
sed -n '420,435p' configure.acRepository: DashCoreAutoGuix/dash
Length of output: 913
🏁 Script executed:
sed -n '1870,1890p' configure.acRepository: DashCoreAutoGuix/dash
Length of output: 580
🏁 Script executed:
git log --oneline -n 20 -- configure.ac | head -5Repository: DashCoreAutoGuix/dash
Length of output: 139
🏁 Script executed:
rg "SANITIZER_CFLAGS" --type-list | head -20Repository: DashCoreAutoGuix/dash
Length of output: 454
🏁 Script executed:
rg "SANITIZER_CFLAGS" . --type makefile --type cmakeRepository: DashCoreAutoGuix/dash
Length of output: 97
🏁 Script executed:
rg "SANITIZER_CFLAGS" . -g "Makefile*" -g "*.in" -g "*.mk"Repository: DashCoreAutoGuix/dash
Length of output: 47
🏁 Script executed:
sed -n '1920,1930p' configure.acRepository: DashCoreAutoGuix/dash
Length of output: 419
🏁 Script executed:
rg -n "SANITIZER_" configure.ac | grep -E "(CFLAGS|CXXFLAGS|LDFLAGS)"Repository: DashCoreAutoGuix/dash
Length of output: 485
Add AC_SUBST(SANITIZER_CFLAGS) to configure.ac.
SANITIZER_CFLAGS is defined at line 426 alongside SANITIZER_CXXFLAGS, but only SANITIZER_CXXFLAGS and SANITIZER_LDFLAGS are AC_SUBST'd at lines 1876-1877. Without AC_SUBST, SANITIZER_CFLAGS won't be available to Makefiles. The export at line 1924 only propagates flags to the secp256k1 subdirectory, not to the main build system. Add AC_SUBST(SANITIZER_CFLAGS) after line 1876 to ensure consistent handling across all sanitizer flag types.
🤖 Prompt for AI Agents
In configure.ac around lines 1876–1877 and referenced at 1923–1925,
SANITIZER_CFLAGS is set earlier but not AC_SUBST'd, so it won't be propagated
into Makefiles; add an AC_SUBST(SANITIZER_CFLAGS) call immediately after the
existing AC_SUBST for SANITIZER_CXXFLAGS/LDFLAGS (i.e., after line 1876) so
SANITIZER_CFLAGS is substituted into generated Makefiles and available to the
main build system.
✅ Verification Complete - APPROVEDBitcoin Commit: e3b68b3 (PR bitcoin#28875) Validation Fixes AppliedThe previous verification agent correctly identified and fixed scope creep in configure.ac:
These were informational echo statements that had extra sanitizer variables beyond what Bitcoin PR bitcoin#28875 added. Backport Analysis
Changes Verified
CI Status
CI Failures Analysis:
These failures are spurious infrastructure issues because:
ConclusionThe validation fixes were correct and the backport is faithful to Bitcoin PR bitcoin#28875. The CI failures are infrastructure-related OOM issues, not caused by the code changes. Status: ✅ APPROVED |
Backports bitcoin#28875
Original commit: e3b68b3
Backported from Bitcoin Core v0.27
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.