From e300f15328f26d221aa1dfd53f57de2ebd098dc9 Mon Sep 17 00:00:00 2001 From: olgeni Date: Sun, 31 Dec 2006 23:27:18 +0000 Subject: Fix R11B-2 SMP timer race condition bug. Obtained from: Rickard Green --- lang/erlang/Makefile | 2 +- lang/erlang/files/patch-erts_emulator_beam_utils.c | 36 ++++++++++++++++++++++ lang/erlang14/Makefile | 2 +- .../files/patch-erts_emulator_beam_utils.c | 36 ++++++++++++++++++++++ 4 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 lang/erlang/files/patch-erts_emulator_beam_utils.c create mode 100644 lang/erlang14/files/patch-erts_emulator_beam_utils.c (limited to 'lang') diff --git a/lang/erlang/Makefile b/lang/erlang/Makefile index 785021b672aa..252635012826 100644 --- a/lang/erlang/Makefile +++ b/lang/erlang/Makefile @@ -7,7 +7,7 @@ PORTNAME= erlang PORTVERSION= r11b2 -PORTREVISION= 1 +PORTREVISION= 2 PORTEPOCH= 1 CATEGORIES= lang parallel MASTER_SITES= http://www.erlang.org/download/ \ diff --git a/lang/erlang/files/patch-erts_emulator_beam_utils.c b/lang/erlang/files/patch-erts_emulator_beam_utils.c new file mode 100644 index 000000000000..58e675168a85 --- /dev/null +++ b/lang/erlang/files/patch-erts_emulator_beam_utils.c @@ -0,0 +1,36 @@ + +$FreeBSD$ + +--- erts/emulator/beam/utils.c.orig ++++ erts/emulator/beam/utils.c +@@ -2999,15 +2999,16 @@ + static void + ptimer_timeout(ErtsSmpPTimer *ptimer) + { +- if (!(ptimer->timer.flags & ERTS_PTMR_FLG_CANCELLED)) { + if (is_internal_pid(ptimer->timer.id)) { + Process *p; +- p = erts_pid2proc(NULL, +- 0, +- ptimer->timer.id, +- ERTS_PROC_LOCK_MAIN|ERTS_PROC_LOCK_STATUS); ++ p = erts_pid2proc_opt(NULL, ++ 0, ++ ptimer->timer.id, ++ ERTS_PROC_LOCK_MAIN|ERTS_PROC_LOCK_STATUS, ++ ERTS_P2P_FLG_ALLOW_OTHER_X); + if (p) { +- if (!(ptimer->timer.flags & ERTS_PTMR_FLG_CANCELLED)) { ++ if (!p->is_exiting ++ && !(ptimer->timer.flags & ERTS_PTMR_FLG_CANCELLED)) { + ASSERT(*ptimer->timer.timer_ref == ptimer); + *ptimer->timer.timer_ref = NULL; + (*ptimer->timer.timeout_func)(p); +@@ -3028,7 +3029,6 @@ + erts_smp_io_unlock(); + } + } +- } + free_ptimer(ptimer); + } + diff --git a/lang/erlang14/Makefile b/lang/erlang14/Makefile index 785021b672aa..252635012826 100644 --- a/lang/erlang14/Makefile +++ b/lang/erlang14/Makefile @@ -7,7 +7,7 @@ PORTNAME= erlang PORTVERSION= r11b2 -PORTREVISION= 1 +PORTREVISION= 2 PORTEPOCH= 1 CATEGORIES= lang parallel MASTER_SITES= http://www.erlang.org/download/ \ diff --git a/lang/erlang14/files/patch-erts_emulator_beam_utils.c b/lang/erlang14/files/patch-erts_emulator_beam_utils.c new file mode 100644 index 000000000000..58e675168a85 --- /dev/null +++ b/lang/erlang14/files/patch-erts_emulator_beam_utils.c @@ -0,0 +1,36 @@ + +$FreeBSD$ + +--- erts/emulator/beam/utils.c.orig ++++ erts/emulator/beam/utils.c +@@ -2999,15 +2999,16 @@ + static void + ptimer_timeout(ErtsSmpPTimer *ptimer) + { +- if (!(ptimer->timer.flags & ERTS_PTMR_FLG_CANCELLED)) { + if (is_internal_pid(ptimer->timer.id)) { + Process *p; +- p = erts_pid2proc(NULL, +- 0, +- ptimer->timer.id, +- ERTS_PROC_LOCK_MAIN|ERTS_PROC_LOCK_STATUS); ++ p = erts_pid2proc_opt(NULL, ++ 0, ++ ptimer->timer.id, ++ ERTS_PROC_LOCK_MAIN|ERTS_PROC_LOCK_STATUS, ++ ERTS_P2P_FLG_ALLOW_OTHER_X); + if (p) { +- if (!(ptimer->timer.flags & ERTS_PTMR_FLG_CANCELLED)) { ++ if (!p->is_exiting ++ && !(ptimer->timer.flags & ERTS_PTMR_FLG_CANCELLED)) { + ASSERT(*ptimer->timer.timer_ref == ptimer); + *ptimer->timer.timer_ref = NULL; + (*ptimer->timer.timeout_func)(p); +@@ -3028,7 +3029,6 @@ + erts_smp_io_unlock(); + } + } +- } + free_ptimer(ptimer); + } + -- cgit