fix: silence GCC 13 -Wstringop-overflow false positive in native tests - #782
Merged
Merged
Conversation
GCC 12/13 (e.g. 13.3 on Ubuntu 24.04) emit a -Wstringop-overflow false
positive ('writing 8 bytes into a region of size 3') when inlining
std::vector<char>::insert(end, ptr, ptr+N) through LogImage::appendF64
into the LogImage constructor in transaction_log_recovery_test.cc.
Grow the vector first and write directly into it instead — same bytes,
no range-insert for the optimizer to mis-model.
transaction_log_validation_test.cc has a byte-for-byte identical helper;
it happens not to warn today (its constructor args are runtime values),
but it gets the same rewrite so the sibling helpers stay consistent and
out of this GCC diagnostic family.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors the vector insertion logic in transaction_log_recovery_test.cc and transaction_log_validation_test.cc to use a grow-then-write pattern (resize followed by direct write) instead of insert. This change is accompanied by comments explaining that it avoids a GCC 12/13 -Wstringop-overflow false positive. There are no review comments to address, and I have no additional feedback to provide.
Contributor
📊 Benchmark Resultsget-sync.bench.tsgetSync() > random keys - small key size (100 records)
getSync() > sequential keys - small key size (100 records)
ranges.bench.tsgetRange() > small range (100 records, 50 range)
realistic-load.bench.tsRealistic write load with workers > write variable records with transaction log
transaction-log.bench.tsTransaction log > read 100 iterators while write log with 100 byte records
Transaction log > read one entry from random position from log with 1000 100 byte records
worker-put-sync.bench.tsputSync() > random keys - small key size (100 records, 10 workers)
worker-transaction-log.bench.tsTransaction log with workers > write log with 100 byte records
Results from commit 40b2704 |
kriszyp
approved these changes
Aug 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GCC 12/13 (e.g. 13.3.0 on Ubuntu 24.04) emit a
-Wstringop-overflowfalse positive when compilingtest/native/transaction_log_recovery_test.cc:This is the known GCC 12/13 false-positive family on
std::vector<char>::insert(end, ptr, ptr+N)under inlining — the optimizer sizes the copy against the pre-grow capacity. The code is correct; only the diagnostic is wrong.Fix
Rewrite the three
LogImageappend helpers (appendU8/appendU32/appendF64) to grow-then-write:resize()the vector, then write directly intobytes.data() + offvia the existingrocksdb_js::writeUint8/writeUint32BE/writeDoubleBEhelpers. Same bytes produced, but no range-insert for the optimizer to mis-model — more robust than areserve()workaround, which would only mask this one inline chain.transaction_log_validation_test.cchas a byte-for-byte identical helper. It happens not to warn today (its constructor takes runtime arguments, which blocks the const-propagation chain), but it gets the same rewrite so the sibling helpers stay consistent and out of this diagnostic family.Verification
Fresh Ubuntu 24.04 container (podman), g++ 13.3.0-6ubuntu2~24.04.1, Node 24, full
node scripts/native-test/run.mjsbuilds:stringop-overflowmain(repro)*
FileLock.SharedHardFailsOnPermissionDeniedskips when running as root.Also verified on macOS (clang): both TUs compile clean, 104 ran, 101 passed + 3 platform-conditional madvise skips.
Pre-existing on
main(confirmed at 3ea9a0f), unrelated to #780.🤖 Generated with Claude Code