python: Fix PyEvent reference counting bug

The current implementation of reference counting for PyEvents only
partially works. The native object is currently kept alive while it is
in the event queue. However, if the Python object goes out of scope,
the Python side of this object is garbage collected which leaves a
"dangling" native object. This results in confusing error messages
where PyBind is unable to find the Python implementation of an event
when it is triggered.

Implement reference counting using the generalized reference counting
API instead.

Change-Id: I4e8e04abc4f61dff238d718065f5371e73b38ab3
Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-by: Curtis Dunham <curtis.dunham@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/3222
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
This commit is contained in:
Andreas Sandberg
2017-05-10 10:57:27 +01:00
parent 5b3752c372
commit 642818f1f3
2 changed files with 44 additions and 46 deletions

View File

@@ -44,7 +44,8 @@ import m5
import _m5.event
from _m5.event import GlobalSimLoopExitEvent as SimExit
from _m5.event import Event, getEventQueue, setEventQueue
from _m5.event import PyEvent as Event
from _m5.event import getEventQueue, setEventQueue
mainq = None