-
Notifications
You must be signed in to change notification settings - Fork 261
try_process_exit() should wait for the async helper thread to exit #440
Comments
In final squashed commit log, gramineproject#440 should be mentioned. Signed-off-by: Isaku Yamahata <[email protected]>
+1 |
Using put_thread(self) to free resources by itself is problematic because the exiting thread is still using them. Actually, put_thread(self) logic in ipc/async helper may cause SEGV depending on who is the last to put_thread(). If the thread is the last one to free thread area, lock/unlock after freeing thread area causes SEGV due to debug message. The solution is to keep reference count of those two helper threads by a (usually master) thread so that the (master) thread will be the last thread to release the reference count. This way self destruction can be avoided. To completely fix this issue, helper threads need to be waited to exit. The issue is tracked by gramineproject#440. Signed-off-by: Isaku Yamahata <[email protected]>
FYI: #321 was just merged to master. |
Some additional info on a related issue in code. The termination of IPC Helper Thread checks for the state The benign issue is that termination functionality is unnecessarily duplicated: int try_process_exit (int error_code, int term_signal) {
... /* code below simplified */
int ret = exit_with_ipc_helper(true, &ipc_thread);
shim_clean(ret);
}
static void shim_ipc_helper (void * arg) { /* in newer commits may be called shim_ipc_helper_end */
...
end:
COMPILER_BARRIER();
if (ipc_helper_state == HELPER_HANDEDOVER) {
debug("ipc helper thread is the last thread, process exiting\n");
shim_terminate(0); // Same as shim_clean(), but this is the official termination function
}
...
} So, It's a benign issue but must be fixed to only have one point of process termination. (See also PR #648) |
Update of the issue wrt the current state of Graphene: |
The async worker thread is currently spawned on-demand and terminated after an idle timeout. This is entirely unnecessary — the cost of having a persistent async thread is near-0, and it simplifies the logic. Fixes gramineproject/graphene#440.
This issue is to track the issue found by #321
try_process_exit() should wait for async helper thread to exit and then release their reference count for final resource release.
Now there is TODO comment to do so because it requires new PAL interface to wait other thread to exit.
The text was updated successfully, but these errors were encountered: