From f7ff71bd463de2435ccda88ae185a021f4efa077 Mon Sep 17 00:00:00 2001 From: hsc Date: Wed, 24 Oct 2012 15:40:57 +0000 Subject: [PATCH] Revert "ListenerManager bugfix (segfault): [...]" This commit *introduced* a segfault to the nanojpeg experiment. Indeed there is no point in clearing m_FireList here: 1. Multiple active listeners match an event coming from the simulator. These listeners are moved from their queue to m_FireList. 2. In a loop iterating over m_FireList, one of the listeners is triggered (ListenerManager::triggerActiveListeners()). Context switches to an experiment. The experiment explicitly (or implicitly, e.g., by terminating) calls simulator.clearListeners(). 3. ListenerManager::remove() clears all active (but not currently fired, or about to be fired) listeners from the main listener queue (and additionally all type-specific special containers). To prevent the "about to be fired" listeners to fire, they are copied to m_DeleteList. 4. The loop mentioned in 2. does not trigger any listener mentioned in m_DeleteList. Afterwards, m_FireList (and m_DeleteList) is cleared. Clearing m_FireList in step 3 invalidates the iterator used in the loop from steps 2 and 4. In fact, this problem was the reason we introduced the m_DeleteList workaround in the first place. This reverts commit r1817. git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1818 8c4709b5-6ec9-48aa-a5cd-a96041d1645a --- src/core/sal/ListenerManager.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/sal/ListenerManager.cc b/src/core/sal/ListenerManager.cc index b537c3d3..6d6184b4 100644 --- a/src/core/sal/ListenerManager.cc +++ b/src/core/sal/ListenerManager.cc @@ -160,7 +160,6 @@ void ListenerManager::remove(ExperimentFlow* flow) (*it)->clear(); // All remaining active listeners must not fire anymore m_DeleteList.insert(m_DeleteList.end(), m_FireList.begin(), m_FireList.end()); - m_FireList.clear(); } else { // remove all listeners corresponding to a specific experiment ("flow"): for (index_t i = 0; i < m_BufferList.size(); ) { if (m_BufferList[i]->getParent() == flow) {