Geotoolkit

Deadlock vulnerability between ThreadedEpsgFactory and FactoryFinder

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 3.00, 3.01, 3.02, 3.03, 3.04, 3.05, 3.06
  • Fix Version/s: 3.07
  • Component/s: Referencing
  • Labels:

Description

When FactoryFinder.getCRSAuthorityFactory(...) is invoked extensively in a multi-thread environment, there is sometime a deadlock:

  • AuthorityFactoryFinder.getCRSAuthorityFactory(...) holds a lock on AuthorityFactoryFinder.class
  • ThreadedAuthorityFactory.availability() holds a lock on this
  • Both of the above methods wait for the lock of the other one (indirectly, the call stack is somewhat deep).

The easy fix is to remove the synchronized statement on ThreadedAuthorityFactory.availability(), which was not strictly necessary since the method implementation was already thread-safe (provided that the status field is made volatile). The cost is that the same work may be done twice, but I don't think it will happen often in practice.

However we should take the opportunity for reducing a bit more the amount of locks, especially in createBackingStore(), because the later invoke client code that we may not control. Even in the case of Geotk implementation, the call stack is deep with recursive calls to FactoryFinder. We are safer to arrange the code in such a way that createBackingStore() is invoked outside any synchronized block.

Activity

There are no comments yet on this issue.

People

Vote (0)
Watch (0)

Dates

  • Created:
    09/Dec/2009 18:59
    Updated:
    13/Apr/2011 15:34
    Resolved:
    13/Apr/2011 15:34

Time Tracking

Estimated:
2h
Original Estimate - 2 hours
Remaining:
0m
Remaining Estimate - 0 minutes
Logged:
2h
Time Spent - 2 hours