Repository navigation
fix: report a wasm plugin running out of stack as an error for the file, and give wasm 8 MiB of stack - #1463
Merged
Merged
Conversation
…le, and give wasm 8 MiB of stack A plugin that ran out of stack on a deeply nested file trapped, was reinitialized, ran out of stack again on the same file, and stopped the whole run with a critical error. Running out of stack is now an error for that file: the instance is dropped without formatting the file again, and the other files still format. Plugins compiled from managed languages have large frames, so 1 MiB of wasm stack ran out at a few hundred levels of nesting where the same code in V8 goes about twice as deep. 8 MiB goes deeper than that. The stack is reserved address space that is committed as it's touched. The test plugin is rebuilt with a case that runs out of stack. The binary that was checked in was older than its source, which says it formats a range, so the notebook test now expects the range to be given as it is.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A wasm plugin that ran out of stack on a deeply nested file trapped, was reinitialized, ran out of stack again on the same file, and then stopped the whole run with "Critical error ... Cannot continue". None of the other files were formatted.
Running out of stack (wasmtime's
Trap::StackOverflow) is now an error for that file only:dprint drops the instance that trapped without formatting the file again, and the other files still format. This also fixes the check after reinitializing, which looked at
original_errwhere it meantreinitialize_err.The wasm stack goes from 1 MiB to 8 MiB, and wasmtime's async stack size is set to match because wasmtime requires it to be larger. Plugins compiled from managed languages have large frames: Prettier compiled to Wasm ran out at a few hundred levels of nesting, about half of what Prettier gets in V8. With 8 MiB it goes 8 times as deep, which is further than V8 for every kind of nesting measured:
a + a + ...(TS)else ifchainf(f(...))<div>The thread stacks are reserved address space that the OS commits as it's touched, so this costs no memory until a file goes that deep. Every release target is 64-bit.
The test plugin is rebuilt with a
should_overflow_stackcase. The binary that was checked in was older than its source, which says the plugin formats a range (supports_range_formatting: true). With the rebuilt binary, the notebook test gives the plugin the range as it is. Expanding a range to whole lines is still covered byshould_only_expand_the_range_for_plugins_that_do_not_format_one.