aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_nif.c
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2017-06-14 11:57:13 +0200
committerLukas Larsson <[email protected]>2017-06-15 10:04:50 +0200
commitb2f7b51f420a233a41c885d8b44919d88f1e7ba5 (patch)
tree59ef0ec698e310218908759aa9404c6308e525c9 /erts/emulator/beam/erl_nif.c
parentf7c9c43c08fd46d89f2a5bf1d055f431dd3812dc (diff)
downloadotp-b2f7b51f420a233a41c885d8b44919d88f1e7ba5.tar.gz
otp-b2f7b51f420a233a41c885d8b44919d88f1e7ba5.tar.bz2
otp-b2f7b51f420a233a41c885d8b44919d88f1e7ba5.zip
erts: Must have main lock when flushing trace messages
If we don't have the main lock, multiple threads may come in and do the flush at the same time which will lead to all kinds of strang problems.
Diffstat (limited to 'erts/emulator/beam/erl_nif.c')
-rw-r--r--erts/emulator/beam/erl_nif.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/erts/emulator/beam/erl_nif.c b/erts/emulator/beam/erl_nif.c
index 4815e5e7bb..8ed429b214 100644
--- a/erts/emulator/beam/erl_nif.c
+++ b/erts/emulator/beam/erl_nif.c
@@ -588,6 +588,10 @@ int erts_flush_trace_messages(Process *c_p, ErtsProcLocks c_p_locks)
ErlTraceMessageQueue *msgq, **last_msgq;
int reds = 0;
+ /* Only one thread at a time is allowed to flush trace messages,
+ so we require the main lock to be held when doing the flush */
+ ERTS_SMP_CHK_HAVE_ONLY_MAIN_PROC_LOCK(c_p);
+
erts_smp_proc_lock(c_p, ERTS_PROC_LOCK_TRACE);
msgq = c_p->trace_msg_q;