sim: Deschedule existing events when destructing an event queue.
authorGabe Black <gabeblack@google.com>
Sat, 17 Nov 2018 00:27:58 +0000 (16:27 -0800)
committerGabe Black <gabeblack@google.com>
Tue, 20 Nov 2018 21:28:48 +0000 (21:28 +0000)
Other objects in the simulation may try to deschedule their events when
destructed, and if they're cleaned up after the event queue is then
they might try to deschedule events on an event queue that no longer
exists.

Change-Id: I9452ce52fba78297ce3dc4b3884289b5e2f2574d
Reviewed-on: https://gem5-review.googlesource.com/c/14400
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Gabe Black <gabeblack@google.com>

src/sim/eventq.hh

index 781bcdbf98e9170700357b7c34d61937c1228383..6e8e63338dd7822f60354ee84ac2dde36ed47dce 100644 (file)
@@ -711,7 +711,11 @@ class EventQueue
      */
     void checkpointReschedule(Event *event);
 
-    virtual ~EventQueue() { }
+    virtual ~EventQueue()
+    {
+        while (!empty())
+            deschedule(getHead());
+    }
 };
 
 void dumpMainQueue();