Skip to content

Commit 02b10a3

Browse files
committed
Fix unsafe access to process struct from dirty sched
1 parent 6b80c62 commit 02b10a3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

erts/emulator/beam/erl_proc_sig_queue.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5086,6 +5086,7 @@ sync_suspend_reply(Process *c_p, ErtsMessage *mp, erts_aint32_t state)
50865086
*/
50875087
Process *rp;
50885088
ErtsSyncSuspendRequest *ssusp;
5089+
int is_managed;
50895090

50905091
ssusp = (ErtsSyncSuspendRequest *) (char *) (&mp->hfrag.mem[0]
50915092
+ mp->hfrag.used_size);
@@ -5105,7 +5106,10 @@ sync_suspend_reply(Process *c_p, ErtsMessage *mp, erts_aint32_t state)
51055106
mp->data.attached = ERTS_MSG_COMBINED_HFRAG;
51065107
mp->next = NULL;
51075108

5108-
rp = erts_proc_lookup(ssusp->requester);
5109+
is_managed = erts_thr_progress_is_managed_thread();
5110+
rp = (is_managed
5111+
? erts_proc_lookup(ssusp->requester)
5112+
: erts_proc_lookup_inc_refc(ssusp->requester));
51095113
if (!rp)
51105114
erts_cleanup_messages(mp);
51115115
else {
@@ -5124,6 +5128,8 @@ sync_suspend_reply(Process *c_p, ErtsMessage *mp, erts_aint32_t state)
51245128
}
51255129
ERL_MESSAGE_TOKEN(mp) = am_undefined;
51265130
erts_queue_proc_message(c_p, rp, 0, mp, ssusp->message);
5131+
if (!is_managed)
5132+
erts_proc_dec_refc(rp);
51275133
}
51285134
}
51295135

0 commit comments

Comments
 (0)