Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 359851 - [prefs] Regression: EclipsePreferences#flush is subject to deadlock due to Open Call via ProjectPreferences / ProfilePreferences
Summary: [prefs] Regression: EclipsePreferences#flush is subject to deadlock due to Op...
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Compendium (show other bugs)
Version: 3.7.1   Edit
Hardware: All All
: P3 critical (vote)
Target Milestone: Juno M3   Edit
Assignee: DJ Houghton CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 376141 (view as bug list)
Depends on: 333726 359698 376141
Blocks: 351231 359485
  Show dependency tree
 
Reported: 2011-10-04 11:01 EDT by DJ Houghton CLA
Modified: 2012-04-05 13:14 EDT (History)
17 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description DJ Houghton CLA 2011-10-04 11:01:49 EDT
Cloned to track release into master.

+++ This bug was initially created as a clone of Bug #359698 +++

+++ This bug was initially created as a clone of Bug #333726 +++

Build ID: Eclipse 3.7.1

The change from bug 333726 introduces a "synchronized" block for the
EclipsePreferences#flush() method. Bug 359485 has a detailed stack trace and analysis why this change causes CDT to deadlock. 

The problem is that from inside the (now synchronized) flush() method, a number of protected methods are called. These "open calls" bear the risk of deadlock. In this case, ProjectPreferences#save() extends EclipsePreferences, and from inside its save() method may perform a Thread switch to update the workspace, which may in turn call resource listeners. Those Thread switches occur with the synchronized block still holding a lock, causing CDT (and potentially others) to deadlock.

I think there are 2 problems with the current situation:

1. Given that there are Open Calls from inside the flush() method, a
   "synchronized" statement on method level is not appropriate (as any 
   book on Java Concurrency will confirm). A different way should be found
   to fix the problem from bug 333726.

2. ProjectPreferences extends EclipsePreferences, thus violating the API 
   boundary and "hiding" the fact that there are Open Calls. I'm wondering
   whether we could either (a) avoid that kind of non-API usage or 
   (b) improve comments or tooling to make it more apparent that protected
   method calls from EclipsePreferences are in fact Open Calls.

   In fact, ProfilePreferences in equinox.p2 has the same problem -- it also
   schedules a SaveJob from inside its save() method thus causing Thread
   Switch and potential deadlock.
Comment 2 John Arthorne CLA 2012-04-05 13:14:55 EDT
*** Bug 376141 has been marked as a duplicate of this bug. ***