Fix jump buffer leak in WASI builds #13142
Merged
+48
−0
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.
This pull request fixes a memory leak in WASI (WebAssembly) builds of Ruby caused by the VM jump buffers not being freed in certain parts of the code.
I originally attempted to fix this memory leak in #12995 (it's the second memory leak mentioned in that pull request), but the fix was reverted by #13026 due to test failures. The fix has been rewritten to be much simpler and less invasive so that it has less of a chance of breaking things.
I've already tested building with this patch here: https://github.com/white-axe/ruby.wasm/actions/runs/14563460222/job/40849624514
For ease of reference, I'm mentioning again here that there's a test to determine if a WASI build of Ruby is affected by the two memory leaks mentioned in #12995:
Note: The first memory leak has been fixed in the master branch so it won't immediately crash from stack buffer overflow anymore, but the test still crashes from running out of memory due to the second memory leak.
Requesting a review from @kateinoigakukun.