-
Notifications
You must be signed in to change notification settings - Fork 2
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
Correct Thread Exiting (for exit()/exec() etc.) #34
Comments
Yeah, this is also an existing bug on exit syscall in lind-wasm that threads aren not terminated when when the main process exit. I wonder what are reliable ways to forcely terminate a running thread? Like pthread_cancel? |
We were handling this using pthread_cancel in lind-nacl, but it was always sort of a workaround since cancelling threads is pretty scary. I talk a bit about a potential solution here: Lind-Project/RawPOSIX#50 (comment) |
Discussed this today with Alice and Qianxi, writing our thoughts down here as a proposal: When reaching a state where all threads in a cage have to exit, they can be in two situations: Untrusted userspace, or trusted space @qianxichen233 has added epoch_interruption for threads, which should allow us to control the behavior of running threads. This should allow us to stop threads that are stuck in userpace. For example, if a thread calls exit()
Things that need to be added to support this:
Because we need to store the epoch handlers, it probably makes sense to store some of thead struct in each wasm Instance containing some of the above information. |
It's plausible that harshexit could / should be called here. We'll need to discuss. If the memory, etc. the process is likely to be unavailable at this point, this is more appropriate than exit. |
I'm realizing this is a bug that we never addressed in NaCl-Lind which is incorrect, we should do this correctly here. The spec for exec says that all threads should be terminated on exec: https://stackoverflow.com/questions/36588387/what-happens-to-threads-when-exec-is-called
This issue is closely related to the issues with exit() we've been talking about here: Lind-Project/RawPOSIX#50
The text was updated successfully, but these errors were encountered: