java/util/Timer uses a binary heap for its TimerTasks, using task.scheduled as
the key. Calling task.cancel() sets task.scheduled=-1, but doesn't update the
Timer binary heap. This can leave the binary heap in an inconsistent state --
the key shouldn't be modified while the task is in the binary heap. This can
lead to situations where newly scheduled TimerTasks aren't moved to the
appropriate position in the heap, so tasks might fire late (since they are stuck
behind tasks that aren't scheduled to fire for a while).

Attaching a proposed fix.

-- 
           Summary: Cancelling a TimerTask puts Timer binary heap in
                    inconsistent state
           Product: gcc
           Version: 3.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: java
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jradel at 2wire dot com
                CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu
                    dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21524

Reply via email to