Fix memory leaks in WASI setjmp handler#12995
Conversation
|
@kateinoigakukun, since you maintain the WASI builds of Ruby, can you take a look at this? |
|
Let me execute ruby.wasm test suite with this change: ruby/ruby.wasm#586 |
|
Here's a test to see if a WASI build is affected by these two memory leaks. This script causes all of the current WASI builds from https://github.com/ruby/ruby.wasm to rapidly consume around 800 mebibytes of memory due to the jump buffer leak and then crash from what I believe is stack buffer overflow caused by the stack pointer leak: loop do
array = [0]
for item in array
break
end
endTo test it out, save it as test.rb in the current working directory, and then: |
kateinoigakukun
left a comment
There was a problem hiding this comment.
Really good catch, the patch looks good to me.
|
Hi @white-axe, the change seems causing OOM on ruby.wasm test suite, so I'm reverting this for now #13026 |
|
I'll find some other way to fix the second memory leak then |
This pull request fixes two memory leaks in the implementation of setjmp in WASI (WebAssembly) builds of Ruby:
rb_vm_tag_jmpbuf_init()andrb_vm_tag_jmpbuf_deinit()to clean up leaked jump buffers before initializing/deinitializing jump buffers.