Opened 17 years ago

Last modified 11 years ago

#14 new defect

Concurrency fixes

Reported by: David Aspinall <da+pgtrac@…> Owned by: David Aspinall
Priority: critical Milestone:
Component: 1:pg-eclipse Keywords:
Cc:

Description

Thread safety in the code needs to be carefully reviewed. Non-deterministic buggy behaviour happens quite often. I'm using this ticket to list places that need work.

Change History (5)

comment:1 Changed 17 years ago by David Aspinall <da+pgrac@…>

Component: documentationproofgeneral-eclipse

comment:2 Changed 17 years ago by David Aspinall <da+pgtrac@…>

Priority: majorcritical

Uses of wait() in the code need to be reviewed. Search for "wait(" or look for notes added in FIXMEs. I've fixed some but not all. Notes:

  • wait() may spuriously wake-up (or wake-up on other conditions), so a specific condition should be checked in a loop
  • notify() may have been sent before wait() was reached, so (unbounded) wait() should not be unconditional

Solution pattern:

synchronized(lock) {
    while (!condition) {
         lock.wait();
    }

where some other thread sets the condition to true before notify or notifyAll. Only use notify if you can be sure there is no more than one thread waiting on the lock.

For more, see the Java Concurrency Tutorial, including this page: http://java.sun.com/docs/books/tutorial/essential/concurrency/guardmeth.html

comment:3 Changed 17 years ago by David Aspinall <da+pgtrac@…>

FindBugs is recommended for helping locate concurrency problems, including these patterns:

  • IS inconsistent synchronisation policy
  • MWN mis-matched wait
  • Wa wait not in loop
  • UW unconditional wait

See #65 for more on FindBugs.

In project properties select "multi-threaded correctness". At the moment we have 25 warnings in this category.

comment:4 Changed 17 years ago by David Aspinall

Milestone: PG-Eclipse-1.0.6PG-Eclipse-1.1.0

comment:5 Changed 11 years ago by David Aspinall

Milestone: PG-Eclipse-1.1.0

Milestone PG-Eclipse-1.1.0 deleted

Note: See TracTickets for help on using tickets.