-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Add -s SAFE_STACK to detect stack overflow #9141
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
Why have a separate setting |
@@ -5162,6 +5162,9 @@ LibraryManager.library = { | |||
}, | |||
// ======================================================================= | |||
|
|||
__handle_stack_overflow: function() { |
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.
__handle_stack_overflow
-> __abort_stack_overflow
?
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.
I don't know if __abort_stack_overflow
is really a good name for the handler function. Binaryen gives the runtime flexibility to do whatever in face of stack overflow. Hypothetically, a runtime could implement a mechanism similar to sigaltstack(2)
to handle stack overflows.
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.
Hmm, now that I look closer at this - does the wasm backend directly generate a call to this function? If so, then the name is very generic. How about __wasm_stack_overflow
? Having compiler backend construct a function call with such a name that does not connect to an established API would make the symbol look somewhat floating.
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.
The WASM backend does not generate a call to this. wasm-emscripten-finalize
in binaryen inserts a call to this function when passed a certain flag. So the __wasm
prefix is inappropriate.
It doesn't do the same thing. |
@@ -242,6 +242,10 @@ var SAFE_HEAP = 0; | |||
// Log out all SAFE_HEAP operations | |||
var SAFE_HEAP_LOG = 0; | |||
|
|||
// Check each stack pointer decrement on WASM backend to ensure that the stack |
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.
nit (not worth a PR): wasm isn't an acronym, so just "wasm" is fine.
Depends on WebAssembly/binaryen#2278 (tests will not pass without it).
Also added a test mode
wasm2ss
to run the whole test suite under-s SAFE_STACK
. It seems to work.Fixes #9039.