aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam
diff options
context:
space:
mode:
authorRickard Green <[email protected]>2017-08-24 15:56:58 +0200
committerRickard Green <[email protected]>2017-08-24 15:56:58 +0200
commit6c8d1ac3112a0cc61849741fd667bbccfa01ee54 (patch)
treec7ab7985a8091f447942c4f45298f049d2b3b059 /erts/emulator/beam
parentb93cc1dc4dadd109ef841b360d7baf99688ce918 (diff)
parenta4a05420aef591bbec457b1762b7aa54666c3ad5 (diff)
downloadotp-6c8d1ac3112a0cc61849741fd667bbccfa01ee54.tar.gz
otp-6c8d1ac3112a0cc61849741fd667bbccfa01ee54.tar.bz2
otp-6c8d1ac3112a0cc61849741fd667bbccfa01ee54.zip
Merge branch 'rickard/btm-auto-cleanup-bug/OTP-14554' into maint
* rickard/btm-auto-cleanup-bug/OTP-14554: Fix BIF timer race between timeout and auto cleanup
Diffstat (limited to 'erts/emulator/beam')
-rw-r--r--erts/emulator/beam/erl_hl_timer.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/erts/emulator/beam/erl_hl_timer.c b/erts/emulator/beam/erl_hl_timer.c
index af1cc6b933..6e5cc7b801 100644
--- a/erts/emulator/beam/erl_hl_timer.c
+++ b/erts/emulator/beam/erl_hl_timer.c
@@ -1273,14 +1273,15 @@ bif_timer_timeout(ErtsHLTimerService *srv,
ERTS_HLT_ASSERT(proc);
}
if (proc) {
+ int dec_refc = 0;
+ ErtsMessage *mp = erts_alloc_message(0, NULL);
+ mp->data.heap_frag = tmr->btm.bp;
+ tmr->btm.bp = NULL;
+ erts_queue_message(proc, 0, mp, tmr->btm.message,
+ am_clock_service);
+ erts_smp_proc_lock(proc, ERTS_PROC_LOCK_BTM);
+ /* If the process is exiting do not disturb the cleanup... */
if (!ERTS_PROC_IS_EXITING(proc)) {
- int dec_refc = 0;
- ErtsMessage *mp = erts_alloc_message(0, NULL);
- mp->data.heap_frag = tmr->btm.bp;
- tmr->btm.bp = NULL;
- erts_queue_message(proc, 0, mp, tmr->btm.message,
- am_clock_service);
- erts_smp_proc_lock(proc, ERTS_PROC_LOCK_BTM);
#ifdef ERTS_MAGIC_REF_BIF_TIMERS
if (tmr->btm.proc_list.next) {
proc_btm_list_delete(&proc->bif_timers, tmr);
@@ -1293,10 +1294,10 @@ bif_timer_timeout(ErtsHLTimerService *srv,
dec_refc = 1;
}
#endif
- erts_smp_proc_unlock(proc, ERTS_PROC_LOCK_BTM);
- if (dec_refc)
- timer_pre_dec_refc((ErtsTimer *) tmr);
}
+ erts_smp_proc_unlock(proc, ERTS_PROC_LOCK_BTM);
+ if (dec_refc)
+ timer_pre_dec_refc((ErtsTimer *) tmr);
}
if (tmr->btm.bp)
free_message_buffer(tmr->btm.bp);