[ playerstage-Patches-3015671 ] ConsumeQueue does not check for empty queue
"SourceForge.net" <[email protected]>
| Newsgroups | gmane.science.robotics.playerstage |
|---|---|
| Message-ID | <[email protected]> |
Patches item #3015671, was opened at 2010-06-14 04:16 Message generated for change (Tracker Item Submitted) made by basilo You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=433166&aid=3015671&group_id=42445 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Stage Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Markus Koenig (basilo) Assigned to: Richard Vaughan (rtv) Summary: ConsumeQueue does not check for empty queue Initial Comment: Hi, currently the Stg::World::ConsumeQueue method has two exit conditions: 1. it stops early if the priority queue is empty when ConsumeQueue starts; 2. otherwise, it consumes events until ev.time > sim_time. If the queue is not empty but ev.time <= sim_time holds for all events in the queue, this results in a pop from an empty queue. This is not a problem as long as an interface remains subscribed, since this continually causes new events to be pushed to the queue (with ev.time > sim_time). This happens while ConsumeQueue is executed. But when the last interface is unsubscribed, no further event will be enqueued, and this triggers the bug. What happens when one pops from an empty priority_queue depends on the C++ library vendor, but on my system (Gentoo, GCC 4.3.3, GNU C++ library 20100121) it returns bogus values. For example, it sometimes returns (Model*) 0x11 as the ev.mod pointer, and then Stage crashes. The attached patch changes ConsumeQueue so that is calls queue.empty() after each handled event and finishes when that becomes true. Might fix bug 2989947: http://sourceforge.net/tracker/?func=detail&aid=2989947&group_id=42445&atid=433164 ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=433166&aid=3015671&group_id=42445 ------------------------------------------------------------------------------ This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first