Reject negative chunk puts and keep pending HT consistent on NOMEM - #2533
Conversation
chunkStorePut hashed and copied nData before checking sign, so a negative size wrapped the write-buf grow and memcpy. Return SQLITE_TOOBIG like PutSparse. Pending hash-table grow assigned nPendingHTSize before the next-index realloc. A NOMEM there left a larger mask over uninitialized buckets. Commit the new size only after both reallocs succeed, then rebuild. Cover both with chunk_store_put_bounds_test: negative puts stay out of the store, and a failed HT grow still finds previously inserted pending chunks. Co-Authored-By: Grok 4.6 <noreply@x.ai>
|
SummaryCoverage spans normal storage and retrieval, duplicate handling, empty and invalid input, persistence across close and reopen, and behavior at large pending-table boundaries. It also exercises adversarial memory-allocation failures and recovery, plus test-selection and feature-toggle behavior, with healthy results across these areas. Safe to merge — the run found no regressions, new failures, or previously reported failures attributable to this PR, and the exercised storage behaviors remain healthy. No merge blocker is indicated; overall risk is low. Tests run by Ito
Tip Reply with @itoqa to send us feedback on this test run. |
DoltLite performance vs PR base
blobpk details
compositepk details
int details
textpk details
vc details
All relative performance gates passed. |
DoltLite source coverage
Merged 202 pooled raw profiles from the distributed Linux correctness jobs. Per-file coverage (98 files)
|

Beta review item 4: two storage-engine footguns.
Negative
chunkStorePutsize.nDatawas hashed and copied before any sign check. A negative length wrapsCS_WAL_CHUNK_HDR_SIZE + nDataas a signed int and is undefined inmemcpy. Reject withSQLITE_TOOBIG, matchingchunkStorePutSparse.Pending hash-table grow on
NOMEM.csPendHTEnsuresetnPendingHTSizeto the new mask before reallocatingaPendingHTNext. If that realloc failed, later lookups used the larger mask over uninitialized buckets and treated garbage as next-indexes. Assign the new size only after both reallocs succeed, then rebuild.test/chunk_store_put_bounds_test.c(coverage C suite):Co-Authored-By: Grok 4.6 noreply@x.ai