Giacomo Travaglini has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/53723 )

Change subject: ext: Fix segfault in simulate_limit_event shortcut
......................................................................

ext: Fix segfault in simulate_limit_event shortcut

In the SST integration the top of the main queue is checked
for an event before starting the simulation.

If the first event is scheduled after the ending tick, we are
just returning the simulate_limit_event without entering
the simulation loop.

If the method is called with an empty queue, the following
line will segfault (getHead() == nullptr):

gem5::mainEventQueue[0]->getHead()->when()

With this patch we are covering the case where we have
an empty event queue

Change-Id: I04463b45b269361172a9dd2fe1ba6e9428ac64f5
Signed-off-by: Giacomo Travaglini <[email protected]>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/53723
Reviewed-by: Hoa Nguyen <[email protected]>
Reviewed-by: Jason Lowe-Power <[email protected]>
Maintainer: Jason Lowe-Power <[email protected]>
Tested-by: kokoro <[email protected]>
---
M ext/sst/gem5.cc
1 file changed, 33 insertions(+), 1 deletion(-)

Approvals:
  Jason Lowe-Power: Looks good to me, approved; Looks good to me, approved
  Hoa Nguyen: Looks good to me, approved
  kokoro: Regressions pass




diff --git a/ext/sst/gem5.cc b/ext/sst/gem5.cc
index 924ee49..c93c722 100644
--- a/ext/sst/gem5.cc
+++ b/ext/sst/gem5.cc
@@ -285,8 +285,10 @@

// Here, if the next event in gem5's queue is not executed within the next
     // cycle, there's no need to enter the gem5's sim loop.
-    if (next_end_tick < gem5::mainEventQueue[0]->getHead()->when())
+    if (gem5::mainEventQueue[0]->empty() ||
+        next_end_tick < gem5::mainEventQueue[0]->getHead()->when()) {
         return gem5::simulate_limit_event;
+    }
     gem5::simulate_limit_event->reschedule(next_end_tick);
     gem5::Event *local_event = doSimLoop(gem5::mainEventQueue[0]);
     gem5::BaseGlobalEvent *global_event = local_event->globalEvent();

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/53723
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I04463b45b269361172a9dd2fe1ba6e9428ac64f5
Gerrit-Change-Number: 53723
Gerrit-PatchSet: 3
Gerrit-Owner: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: Bobby Bruce <[email protected]>
Gerrit-Reviewer: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: Hoa Nguyen <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to