Skip to content

Fix fdb_push bound-param leak in fdb_push_free - #6098

Open
emelialei88 wants to merge 1 commit into
bloomberg:mainfrom
emelialei88:fix-fdb-push-param-leak
Open

Fix fdb_push bound-param leak in fdb_push_free#6098
emelialei88 wants to merge 1 commit into
bloomberg:mainfrom
emelialei88:fix-fdb-push-param-leak

Conversation

@emelialei88

Copy link
Copy Markdown
Contributor

What

Fixes the bound-param leak flagged in #6027 (comment).

dohsql_free_params(&n, &p, count) frees the first count params (while(count--)). fdb_push_free passed p->nparams-1, so the last bound param always leaked — and with a single param (nparams==1) nothing was freed at all.

Fix

  • db/fdb_push.c: pass p->nparams (free all) instead of p->nparams-1.
  • db/dohsql.c: relax the abort guard index >= *pnparamsindex > *pnparams so freeing the full count is valid. The only other caller (the clone error path) passes a count < nparams, so it is unaffected.

Test

tests/fdb_push.test gets a regression subtest (reusing the existing 3-db harness): 100 remote push-inserts of a single 512KB bound blob (nparams==1), asserting the uncategorized memstat bucket — where dohsql clones params — does not balloon.

uncategorized grew result
before fix ~52 MB FAIL
after fix ~7 KB PASS

🤖 Generated with Claude Code

@emelialei88
emelialei88 force-pushed the fix-fdb-push-param-leak branch 2 times, most recently from 9d3a3b9 to 4c7955e Compare July 30, 2026 18:04
dohsql_free_params(&n, &p, count) frees the first `count` params
(while(count--)). fdb_push_free passed p->nparams-1, so the last bound
param always leaked -- and with a single param (nparams==1) nothing was
freed at all.

Pass p->nparams to free all of them, and relax the abort guard from
`index >= *pnparams` to `index > *pnparams` so freeing the full count is
valid (the clone error path still passes a count < nparams).

Adds a regression subtest to fdb_push.test: 100 remote push-inserts of a
single 512KB bound blob, asserting the "uncategorized" memstat bucket
(where dohsql clones params) does not balloon. Grows ~50MB before the fix,
~7KB after.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Emelia Lei <wlei29@bloomberg.net>
@emelialei88
emelialei88 force-pushed the fix-fdb-push-param-leak branch from 4c7955e to 8f73957 Compare July 30, 2026 18:43
@emelialei88
emelialei88 marked this pull request as ready for review July 30, 2026 18:44

@roborivers roborivers left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cbuild submission: Error ⚠.
Regression testing: Success ✓.

The first 10 failing tests are:
consumer_non_atomic_default_consumer_generated **quarantined**
sc_downgrade [timeout] **quarantined**

@roborivers roborivers left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cbuild submission: Error ⚠.
Regression testing: Success ✓.

The first 10 failing tests are:
consumer_non_atomic_default_consumer_generated **quarantined**
sc_downgrade [timeout] **quarantined**

@roborivers roborivers left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cbuild submission: Success ✓.
Regression testing: Success ✓.

The first 10 failing tests are:
sc_resume_logicalsc_generated **quarantined**
consumer_non_atomic_default_consumer_generated **quarantined**
sc_downgrade [timeout] **quarantined**

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants