ci: Do not patch `leveldb` to workaround UB in "tidy" CI job
What changed, and why it matters
This is a small change to Bitcoin Core's continuous integration (CI) script. It stops applying a temporary code patch to the LevelDB database library during one specific CI job (the 'tidy' job). The patch was a workaround for undefined behavior (reading uninitialized memory) in LevelDB. The tidy job only checks code style and include-usage issues, so it doesn't need the patch. The underlying undefined behavior in LevelDB is not fixed by this commit; it just changes when the workaround is applied.
No immediate action is required for this commit alone. However, the referenced undefined behavior in LevelDB should be tracked and properly fixed upstream or in the vendored LevelDB, rather than relying on a temporary CI-only patch. Review whether the UB workaround is still needed and whether it masks a real security or stability issue.
Security signals we found
The commit message and code comment explicitly mention undefined behavior (UB) in LevelDB related to reading uninitialized memory (compact->outputs[i].file_size).
The existing patch is a temporary minimal workaround, not a fix, for the UB issue.
The change is CI-only and does not modify production Bitcoin Core or LevelDB code.
The change does not address the root cause of the UB; it only changes CI configuration.
Evidence from the diff
The commit modifies ci/test/03_test_script.sh to conditionally apply a LevelDB patch only when the CI job is not the ‘tidy’ job. The tidy job uses git diff to detect IWYU (include-what-you-use) errors, and applying a patch would create noise in that diff. The patch itself comments out a stats_.Add(stats) call in LevelDB’s DBImpl::FinishCompactionOutputFile because compact->outputs[i].file_size is uninitialized memory and reading it is undefined behavior. This commit does not remove the workaround for jobs that run UB detectors; it only skips it for the tidy job.
Changed components
ci/test/03_test_script.shLevelDB (indirectly, via CI patching behavior)Bitcoin Core CI 'tidy' jobInspect captured patch +5 / −2
diff --git a/ci/test/03_test_script.sh b/ci/test/03_test_script.sh
index 05e4d8fd..3e07f1c8 100755
--- a/ci/test/03_test_script.sh
+++ b/ci/test/03_test_script.sh
@@ -41,7 +41,10 @@ echo "=== BEGIN env ==="
env
echo "=== END env ==="
-(
+# Don't apply patches in the tidy job, because it relies on the `git diff`
+# command to detect IWYU errors. It is safe to skip this patch in the tidy job
+# because it doesn't run a UB detector.
+if [ "$RUN_TIDY" != "true" ]; then
# compact->outputs[i].file_size is uninitialized memory, so reading it is UB.
# The statistic bytes_written is only used for logging, which is disabled in
# CI, so as a temporary minimal fix to work around UB and CI failures, leave
@@ -62,7 +65,7 @@ echo "=== END env ==="
mutex_.Lock();
stats_[compact->compaction->level() + 1].Add(stats);
EOF
-)
+fi
if [ "$RUN_FUZZ_TESTS" = "true" ]; then
export DIR_FUZZ_IN=${DIR_QA_ASSETS}/fuzz_corpora/
Why this scored 17/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.