Skip to content

crypto: secp256k1_allocation's control calls operator new, which -O3 keeps - #2

Merged
pinhopro merged 1 commit into
mainfrom
fix/release-allocation-control
Nov 17, 2026
Merged

pinhopro merged 1 commit into
mainfrom
fix/release-allocation-control

Conversation

@pinhopro

Copy link
Copy Markdown
Contributor

What

test/secp256k1_allocation_test.cpp's control was delete new int(1). A new-expression's allocation may be elided by the optimizer ([expr.new]), and at variant=release (-O3) on wasip2 and wasip3 it was: the counter did not move and allocations() > control failed, so secp256k1_allocation and secp256k1_allocation_no_exceptions failed there. The control now calls ::operator delete(::operator new(sizeof(int))), a call of the replaceable function that is never elided, the form webcpp::hash's allocation control already uses.

The other allocation tests of crypto (allocation_openssl, allocation_bearssl, counting) and hash (allocation, allocation_openssl) were checked: they allocate through volatile pointers, direct ::operator new calls or OpenSSL's hooks, none through an elidable expression.

Evidence (local, macOS arm64, wasmtime 47.0.3)

  • RED before the change: wasip2 release, secp256k1_allocation_test.cpp(74): test 'webcpp::test::allocations() > control' failed.
  • GREEN after, -a, both programs passed on each of native, wasip2, wasip3, emscripten at release and at debug (8 of 8).

Test-only change, so no changelog line.

🤖 Generated with Claude Code

…keeps

The control was `delete new int(1)`, a new-expression whose allocation the
standard lets the optimizer elide ([expr.new]); at variant=release, -O3 on
wasip2 and wasip3 removed it, the counter did not move, and
secp256k1_allocation and secp256k1_allocation_no_exceptions failed. A call
of ::operator new is never elided, as webcpp::hash's allocation control
already does.
@pinhopro
pinhopro merged commit ae937e5 into main Nov 17, 2026
26 checks passed
@pinhopro
pinhopro deleted the fix/release-allocation-control branch November 19, 2026 02:43
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.

1 participant