-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Fix memory leaks in WASI setjmp handler #12995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
end To test it out, save it as test.rb in the current working directory, and then:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.