Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 344480

Summary: [spell checking] Simultaneously opening many files with spelling problems hogs the CPU (100% usage) and eventually crashes the platform
Product: [Eclipse Project] Platform Reporter: Alex Marin <alex>
Component: TextAssignee: Platform-Text-Inbox <platform-text-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, remy.suen
Version: 3.7Keywords: investigate, performance
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard: stalebug
Attachments:
Description Flags
Testcase project none

Description Alex Marin CLA 2011-05-02 12:12:27 EDT
Build Identifier: 20110218-0911

Simultaneously opening many (100s) files with many (1000s) spelling problems causes Eclipse to take 100% of one or more CPUs of the machine it's running on. Sometimes the platform UI becomes non-responsive and eventually the platform crashes.

This issue is caused by a race condition, and it has been reported to appear even in conditions of less files/spelling problems. However the scenario above is more likely to reproduce the issue.

By using a debugger one notices that when the issue appears, some of the MonoReconciler threads acting on the opened files are stuck in a HashMap iteration. 

The HashMap in discussion is org.eclipse.ui.texteditor.spelling.SpellingReconcileStrategy.SpellingProblemCollector.fAddAnnotations which is created in org.eclipse.ui.texteditor.spelling.SpellingReconcileStrategy.SpellingProblemCollector.beginCollecting(). The root problem is that this HashMap instance is accessed from several threads at once (see http://mailinator.blogspot.com/2009/06/beautiful-race-condition.html for a concurrency p.o.v. explanation). Using a ConcurrentHashMap instead is a possible fix for the problem.





Reproducible: Sometimes

Steps to Reproduce:
1. In the Editors -> Text editors -> Spelling preference page set maximum number of problems reported per file to 9999
2. In a plain project, create many plain text files each containing many badly spelled words (or use the attached project)
3. Open all these files simultaneously
Comment 1 Alex Marin CLA 2011-05-02 12:14:58 EDT
Created attachment 194504 [details]
Testcase project
Comment 2 Dani Megert CLA 2011-05-02 12:16:10 EDT
This is not a realistic scenario, especially when the limit that we added to avoid the performance problem gets increased by the user.
Comment 3 Alex Marin CLA 2011-05-02 13:11:03 EDT
I just want to emphasize that due to its concurrency nature this issue might manifest during "regular" usage as well but with a very low reproducibility.

A real-life use-case we've encountered: 
    * user does not have a dictionary configured (all words in comments are considered spelling issues)
    * user runs a script that generate source files
    * project is refreshed
    * platform simultaneously performs spell-checking on all files that changed on disk

Regards,
    Alex
Comment 4 Lars Vogel CLA 2019-11-14 03:10:55 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

If the bug is still relevant, please remove the "stalebug" whiteboard tag.