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

Fix stack overflow detection #56

Closed
wants to merge 3 commits into from
Closed

Conversation

mikezackles
Copy link

This sketches a fix for #55 if I am understanding things correctly. It has not undergone any sort of rigorous testing.

The previous detection relied on JS_Eval being called from the same or deeper
stack frame than JS_NewRuntime.
I don't think this is exhaustive. This also adds an assert to detect when
js_check_stack_overflow is called outside a guard.

I'm trying to be conservative and wrap the entrypoints explicitly, but maybe it
would make sense to wrap JS_CallInternal instead?
This makes the tests pass again. js_check_stack_overflow seems like it gets
called from lots of entrypoints, so this approach allows for wrapping the most
important ones without worrying about being exhaustive.
@bellard
Copy link
Owner

bellard commented Mar 21, 2021

This solution has no chance to work.

@bellard bellard closed this Mar 21, 2021
@mikezackles
Copy link
Author

mikezackles commented Mar 21, 2021

In retrospect I think I can see that stuff like longjmp would break this. Thanks, and looking forward to the fix.
Edit: I'm not sure what I was thinking as this is obviously not exception safe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants