Repository navigation
Use the whole WebAssembly stack for the stack depth limit - #20
Conversation
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
Review complete. No issues found. This PR extends the WebAssembly stack-depth test harness with a new
Reviewed commit: 83823ad |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
|
Closing this. We're keeping the 512 kB WebAssembly cap and the current stack setup. libpg-query-node will report host stack overflows as stack depth errors instead (constructive-io/libpg-query-node#213). |
|
Reopening: we're removing the 512 kB cap we added in #18. The limit is now the real WASM stack, and libpg-query-node reports host stack overflows as clean stack depth errors. |
…ck depth errors (#213) * test(wasm): parse 18.1.5's depths and report V8 stack overflows as stack depth errors * test(wasm): check parsePlPgSQL's function list and drop a fingerprint case that now parses * fix(wasm): report host stack overflows as stack depth errors and use the full WASM stack * test(wasm): keep the stack depth errors in the heap-release test * fix(wasm): format the overflow's stack so a kept error doesn't pin the dropped instance * test(release-diff): allow 18.2.7's capped depth limits; lower SQL depths that overflow V8 on macOS * chore(v18): pin libpg_query to 18-constructive f9f1b67 (constructive-io/libpg_query#20) * test(v18): drop nested function calls from the 18.1.5 depth test; V8 overflows first on macOS
* test(wasm): parse 18.1.5's depths and report V8 stack overflows as stack depth errors * test(wasm): check parsePlPgSQL's function list and drop a fingerprint case that now parses * fix(wasm): report host stack overflows as stack depth errors and use the full WASM stack * test(wasm): keep the stack depth errors in the heap-release test * fix(wasm): format the overflow's stack so a kept error doesn't pin the dropped instance * test(release-diff): allow 18.2.7's capped depth limits; lower SQL depths that overflow V8 on macOS * test(wasm): normalize deep nesting on an instance that replaced an overflowed one * fix(wasm): pin libpg_query with normalize off the per-level PG_TRY path * chore(v18): pin libpg_query to 18-constructive f9f1b67 (constructive-io/libpg_query#20) * Pin libpg_query to the fingerprint frame fix * test(v18): run the fingerprint and normalize depth tests on Node 20 and raise the normalize limits * chore(v18): pin libpg_query to the fingerprint fix merged with 18-constructive * chore(v18): pin libpg_query to 18-constructive with both depth fixes
Summary
The 512 kB Emscripten cap from #18 still rejects nesting that libpg-query 18.1.5 parsed. It is worst for PL/pgSQL: each nested block uses about 1.5 kB of WebAssembly stack (
dump_stmtand friends), so 512 kB stops at about 350 nestedIF/BEGIN/LOOPblocks. 18.1.5 parsed about 3,300 of them, until bison'smemory exhausted.There is no cap that works for every input. Measured with no cap in libpg-query-node (Node 24, 32 MB
STACK_SIZE), V8's native stack runs out at very different points on the WebAssembly stack:SELECT 1+1+…1+1+…So 512 kB is too small for PL/pgSQL, and normalize already overflows V8 at 142 kB, below any useful cap.
This PR drops the WebAssembly clamp. The limit becomes the linked stack minus
STACK_DEPTH_SLOP, so the check still keeps the WebAssembly stack from overflowing into the heap. A host-stack overflow is left to the embedder; libpg-query-node turns it into the samestack depth limit exceedederror.The WASM depth test now parses 1,000 nested
IFblocks and 3,000 nestedBEGINblocks with the 32 MB stack. The 100,000-term case, which expects the clean error, now runs in a second build linked with a 1 MB stack, where the check fires before V8's stack runs out. The test commit was pushed first and fails on the 512 kB cap.Implemented in session Settle the last old WASM hardening PRs
Review with Devin · Open in Devin Desktop