Skip to content

crypto: drop generateKeyPair ctx's KeyObject ref before invoking the callback - #36657

Closed
robobun wants to merge 4 commits into
mainfrom
farm/9a7d0c03/keypair-exit-leak
Closed

crypto: drop generateKeyPair ctx's KeyObject ref before invoking the callback#36657
robobun wants to merge 4 commits into
mainfrom
farm/9a7d0c03/keypair-exit-leak

crypto: also drop SignJobCtx/DhJobCtx key refs before invoking the ca…

4fd3852
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Aug 1, 2026 in 30m 59s

Code review found 2 potential issues

Found 4 candidates, confirmed 2. See review comments for details.

Details

Severity Count
🔴 Important 0
🟡 Nit 2
🟣 Pre-existing 0
Severity File:Line Issue
🟡 Nit src/bun_alloc/lib.rs:273-274 Crate-root bun_alloc::usable_size is now dead code
🟡 Nit src/jsc/bindings/node/crypto/CryptoGenKeyPair.cpp:65-69 More OPENSSL_malloc'd ctx fields (and two sibling job contexts) remain stranded across the callback

Annotations

Check warning on line 274 in src/bun_alloc/lib.rs

See this annotation in the file changed.

@claude claude / Claude Code Review

Crate-root bun_alloc::usable_size is now dead code

The crate-root `bun_alloc::usable_size` (lib.rs:707) is now dead — this PR rewires its only two callers (`OPENSSL_memory_free` / `OPENSSL_memory_get_size`) to `default_alloc::usable_size`, and it's `pub` so the dead-code lint won't flag it. Per REVIEW.md ("Delete dead code in the same PR that makes it dead … helpers whose last caller you rewired … Public items escape dead-code lints — grep for callers manually"), delete it here.

Check warning on line 69 in src/jsc/bindings/node/crypto/CryptoGenKeyPair.cpp

See this annotation in the file changed.

@claude claude / Claude Code Review

More OPENSSL_malloc'd ctx fields (and two sibling job contexts) remain stranded across the callback

The class this PR fixes — "drop every ctx-owned `OPENSSL_malloc` leaf before re-entering JS, since the TZone/FastMalloc ctx isn't LSan-scanned and `process.exit()` strands whatever it points to" — still has instances in and around the functions this PR modified: `KeyPairJobCtx::m_privateKeyEncoding.passphrase` (a `DataPointer` from `OPENSSL_malloc`, `exportPrivate` takes the config by `const&` so does not consume it), `SignJobCtx::m_signResult` / `DhJobCtx::m_result` (both `ByteSource::allocated