Skip to content

Commit 6b80c62

Browse files
jcpetruzzarickard-green
authored andcommitted
Fix suspend_process() issue on processes in dirty schedulers
# Context `erlang:suspend_process()` was broken when applied on processes that happened to be in a dirty-scheduler. The symptom was: - `internal_error` would be returned when called synchronously - `not_suspended` would be delivered when called asynchronously, even though the process was in fact suspended # Problem When trying to suspend a processes in a dirty-scheduler, it is actually the dirty-scheduler who suspends the process, by calling `erts_proc_sig_handle_pending_suspend()`. This essentially activates all pending suspend monitors and finally sends all pending sync messages, by calling `sync_suspend_reply()`. The problem is that when calling the latter, it is passing the process state *before* activating the monitors. In particular, the SUSPENDED flag is not set, what makes `sync_suspend_reply()` assume that something is wrong.
1 parent 412bff5 commit 6b80c62

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

erts/emulator/beam/erl_proc_sig_queue.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5269,6 +5269,8 @@ erts_proc_sig_handle_pending_suspend(Process *c_p)
52695269
msp = next_msp;
52705270
}
52715271

5272+
state = erts_atomic32_read_nob(&c_p->state);
5273+
52725274
sync = psusp->sync;
52735275

52745276
while (sync) {

0 commit comments

Comments
 (0)