Skip to content
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

Mitigate stack-overflow issue take 2 #302

Merged
merged 5 commits into from
Nov 13, 2023

Conversation

kateinoigakukun
Copy link
Member

@kateinoigakukun kateinoigakukun commented Nov 11, 2023

We had a tentative fix for large stack consumption for setjmp by #235, but it's just a workaround by increasing stack size and not a permanent fix. This PR improves the stack consumption for setjmp, which is the root problem, by allocating buffer in heap instead of stack space.

The fix is going to be applied to the CRuby head, so 3.2 package still has the same issue yet. The tentative larger stack size fix broke some of mobile browsers due to OOM?, so this PR also makes the fiber stack size in 3.2 packages smaller to avoid crash. (note that head package no longer needs larger stack size)

Related issues:

CRuby PR: ruby/ruby#8902

@kateinoigakukun kateinoigakukun force-pushed the katei/mitigate-stackoverflow-part2 branch from 490903d to 12cb216 Compare November 11, 2023 22:44
@kateinoigakukun kateinoigakukun force-pushed the katei/mitigate-stackoverflow-part2 branch from 12cb216 to dd2afc9 Compare November 13, 2023 02:41
Also stop calling `asyncify_stop_unwind` when the main function returns
without any unwinding. In the era when Asyncify buffers were allocated
on the stack, the `top` and `end` fields were remained in the stack
space even after the main function returned, so buffer-overflow check in
the `asyncify_stop_unwind` function worked. But now, the `top` and `end`
fields are part of the jump buffer allocated on the heap and they are
deallocated with `free` when the corresponding VM tag is popped. So, the
buffer-overflow check in the `asyncify_stop_unwind` function failed when
the main fuction returned without any unwinding, and we have to break
the asyncify loop before calling `asyncify_stop_unwind`.
@kateinoigakukun kateinoigakukun force-pushed the katei/mitigate-stackoverflow-part2 branch from dd2afc9 to 57ccc24 Compare November 13, 2023 03:26
@kateinoigakukun kateinoigakukun force-pushed the katei/mitigate-stackoverflow-part2 branch from 57ccc24 to d85b9ea Compare November 13, 2023 03:51
@kateinoigakukun kateinoigakukun merged commit 99f5000 into main Nov 13, 2023
31 checks passed
@kateinoigakukun kateinoigakukun deleted the katei/mitigate-stackoverflow-part2 branch November 13, 2023 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Page crashes on iOS Safari and Chrome when using ruby-head-wasm-wasi@latest
1 participant