From f42ce27065341d72823ddba334c473a5deb06b68 Mon Sep 17 00:00:00 2001 From: Austin Harris Date: Tue, 21 Sep 2021 01:36:06 -0500 Subject: [PATCH] sim: Fix hang while terminating threads with fork It is possible that gem5 is forked multiple times before the threads are re-created, so don't wait for the barrier if the threads were already terminated. Change-Id: Ia04db2f3b1341c4d432178a37812fd882e148ec2 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/50710 Reviewed-by: Andreas Sandberg Maintainer: Andreas Sandberg Tested-by: kokoro --- src/sim/simulate.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sim/simulate.cc b/src/sim/simulate.cc index ec46cbfcda..c5d07942ef 100644 --- a/src/sim/simulate.cc +++ b/src/sim/simulate.cc @@ -118,6 +118,8 @@ class SimulatorThreads terminateThreads() { assert(!terminate); + if (threads.empty()) + return; /* This function should only be called when the simulator is * handling a global exit event (typically from Python). This