This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 426785 - [Help][Search] Querying help content while exiting Eclipse may cause a deadlock preventing a proper shutdown
Summary: [Help][Search] Querying help content while exiting Eclipse may cause a deadlo...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: User Assistance (show other bugs)
Version: 4.4   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 4.4 M6   Edit
Assignee: Paul Webster CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-28 07:41 EST by Holger Voormann CLA
Modified: 2014-06-02 10:14 EDT (History)
1 user (show)

See Also:


Attachments
Plug-in to reproduce deadlock in SearchIndex (1.52 KB, application/octet-stream)
2014-01-28 07:41 EST, Holger Voormann CLA
no flags Details
Patch for bug 426785 (1.57 KB, patch)
2014-01-28 16:26 EST, Holger Voormann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Holger Voormann CLA 2014-01-28 07:41:04 EST
Created attachment 239385 [details]
Plug-in to reproduce deadlock in SearchIndex

Querying help content while exiting Eclipse may cause a deadlock: the help windows stays opened but cannot be used anymore. Even closing the help window does not stop the "eclipse.exe" process.

Steps to reproduce:
1. Copy the attached plug-in
   "plugin.to.reproduce.deadlock.in.SearchIndex_1.0.0.jar"
   into the "dropins" folder of your Eclipse installation folder
2. Start Eclipse
3. Open the help window by choosing "Help > Help Contents"
4. In the help window in the "Contents" view, click on
   "Plug-in to reproduce deadlock in SearchIndex"
5. Close Eclipse by choosing "File > Exit" in the main window
=> Not always but sometime the main window disappears but the help
   window stays opened. Even if the help window is closed,
   the Window Task Manager still shows a running "eclipse.exe" process.

The bug is caused by a deadlock in org.eclipse.help.internal.search.SearchIndex:
The method "close()" waits for all searches to finish. But the code to wait is enclosed by the same "synchronized (searches) {...}" as in "unregisterSearch(Thread t)", which must be called to finish a search.
Comment 1 Paul Webster CLA 2014-01-28 15:24:11 EST
So in theory moving the "synchronized (searches) {" after the "while (searches.size()>0) {" loop would break this deadlock ?

size() usually returns quickly, and the cost of it being wrong during a close() would be pretty low.

PW
Comment 2 Holger Voormann CLA 2014-01-28 16:26:59 EST
Created attachment 239406 [details]
Patch for bug 426785

(In reply to Paul Webster from comment #1)
Yes, the attached patch fixes this issue. By the way, I think the field "closed" must be "volatile" because it is accessed by different threads.

Unfortunately, I failed to contribute via Gerrit: My push was rejected with following error message:
  Repository ssh://hvoormann@git.eclipse.org:29418/platform/eclipse.platform.ua

  prohibited by Gerrit
  Branch refs/heads/master:
  You are not allowed to perform this operation.
  To push into this reference you need 'Push' rights.
  User: hvoormann
  Please read the documentation and contact an administrator
  if you feel the configuration is incorrect

  Processing changes: refs: 1
  Processing changes: refs: 1, done
Comment 3 Paul Webster CLA 2014-01-28 16:59:36 EST
You need to push to HEAD:refs/for/master 

PW
Comment 4 Holger Voormann CLA 2014-01-28 17:04:51 EST
(In reply to Paul Webster from comment #3)
> You need to push to HEAD:refs/for/master 
> 
> PW

Success! :-)
https://git.eclipse.org/r/21224
Comment 5 Paul Webster CLA 2014-01-28 19:49:10 EST
Released as http://git.eclipse.org/c/platform/eclipse.platform.ua.git/commit/?id=30ba8ea359acc60d26bbbc47684874777aefaff0  I just updated the comment to use Bug .... as the comment title.

Thanks Holger!

I've released http://git.eclipse.org/c/platform/eclipse.platform.ua.git/commit/?id=acce130be709cb2373506a9e7aa97ec8293cc409 to update versions and copyright.

PW
Comment 6 Dani Megert CLA 2014-04-08 08:52:31 EDT
(In reply to Paul Webster from comment #5)
> I've released
> http://git.eclipse.org/c/platform/eclipse.platform.ua.git/commit/
> ?id=acce130be709cb2373506a9e7aa97ec8293cc409 to update versions and
> copyright.

What was the reason to do that? It was already increased for 4.4. Just wondering.
Comment 7 Paul Webster CLA 2014-04-08 10:05:27 EDT
(In reply to Dani Megert from comment #6)
> 
> What was the reason to do that? It was already increased for 4.4. Just
> wondering.

That was a mistake on my part.  I use:
git diff R4_3..HEAD -- org.eclipse.help.base/META-INF/MANIFEST.MF

To see if it has been changed since 4.3, and I misread the result.

PW
Comment 8 Wojciech Sudol CLA 2014-06-02 10:14:05 EDT
I tried to reproduce the bug in I20140528-2000 (around 20 attempts) and it happened once. In 4.4 M3 I am able to reproduce it almost every time.