Hi!

Negative priorities can cause random memory corruption (writing to
unrelated memory areas) and endless loops in Event.

The reason is that often events are being queued in loops. Negative
priorities cause the handler to be executed immediately, which can result in
any number of changes to the event rings, invalidating the iteration
variables used by Event.

As a concrete example take pe_timeables_check. It stores the tm->ring.next
value in a local variable, then calls the alarm method of the watcher,
which might do any number of things to next, including removing it from
the ring (resulting in an endless loop as next->ring.next == next) or
calling further methods on it after next has been freed.

The reason I use negative priorities is, unfortunately, not due to this
side-effect but due to the fact that Event creates all Event handlers with
the highest normal priority, leaving no leeway to create higher priority
watchers without using the asynchronous ones.

Not sure how this bug can be fixed safely without sacrificing the async
property of negative priorities.

-- 
                The choice of a
      -----==-     _GNU_
      ----==-- _       generation     Marc Lehmann
      ---==---(_)__  __ ____  __      [EMAIL PROTECTED]
      --==---/ / _ \/ // /\ \/ /      http://schmorp.de/
      -=====/_/_//_/\_,_/ /_/\_\      XX11-RIPE

Reply via email to