-
Notifications
You must be signed in to change notification settings - Fork 724
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
wasm2c runtime: refactor handling of alternate stack (NFC) #2338
Conversation
13b51d2
to
1744164
Compare
wasm2c/wasm-rt-impl.c
Outdated
stderr, | ||
"wasm-rt error: tried to re-allocate thread-local alternate stack\n"); | ||
abort(); | ||
} |
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'm not sure what the convention is within this file, but would it make sense to write these 6 lines as assert(!g_alt_stack && "wasm-rt error: tried to re-allocate thread-local alternate 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.
Sure, done.
#ifndef NDEBUG | ||
fprintf(stderr, | ||
"wasm-rt warning: alternate stack was modified unexpectedly\n"); | ||
#endif |
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.
And this could just be assert(false && ..
?
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'd rather not make this one abort() on failure, since it seems plausible the application would install its own altstack at some point, and that shouldn't be (in my view) an abort-style fatal error...
The runtime installs an alternate stack to handle SIGSEGV from stack exhaustion. Make this variable thread-local and refactor implementation that touches it.
ced0cfe
to
da016f8
Compare
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.
lgtm % final nit/comment
sa.sa_flags = SA_SIGINFO | SA_ONSTACK; | ||
#endif |
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.
How about:
sa.sa_flags = SA_SIGINFO;
#if !WASM_RT_USE_STACK_DEPTH_COUNT
sa.sa_flags |= SA_ONSTACK;
#endif
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.
Sure, done.
Split out from #2332.
This makes the
g_alt_stack
variable thread-local and splits out the internal routines that handle allocation/installation. This will make it a smaller change to add the per-thread initialization API in #2332.