Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 343948 - Shared ast is exposed for concurrent usage
Summary: Shared ast is exposed for concurrent usage
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-editor (show other bugs)
Version: 8.0   Edit
Hardware: PC Windows 7
: P3 major (vote)
Target Milestone: 8.0   Edit
Assignee: Anton Leherbauer CLA
QA Contact: Anton Leherbauer CLA
URL:
Whiteboard:
Keywords:
: 343175 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-04-27 08:55 EDT by Markus Schorn CLA
Modified: 2011-05-03 13:15 EDT (History)
3 users (show)

See Also:
eclipse.sprigogin: review+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Schorn CLA 2011-04-27 08:55:15 EDT
The shared ast is exposed to the ASTProvider before the reconciler is done. To reproduce set a breakpoints:

* Set a breakpoint in CEditor.reconciled(..) in the line where the listeners    
  are notified.
* Make a change to the file in the editor and wait until the breakpoint is hit.
* Set another breakpoint in ASTCache.runOnAST(...)
* Select a name in the editor and select F3.
--> The second breakpoint is hit in a different thread with access to the same
    ast.
Comment 1 Anton Leherbauer CLA 2011-04-27 10:34:52 EDT
Previously, the ast was protected by wrapping the runOnAst in a synchronized (ast) block:

  synchronized (ast) {
    return astRunnable.runOnAST(lang, ast);
  }

The same is done in the reconciler calling the IReconcilingListeners:

  synchronized (ast) {
    ((ICReconcilingListener)fEditor).reconciled(ast, forced, fProgressMonitor);
  }

Now we have two different methods.  ASTCache uses IASTTranslationUnit.beginExclusiveAccess() while the reconciler still uses the old method.
Comment 2 Anton Leherbauer CLA 2011-05-02 03:54:52 EDT
I committed a fix to use begin/endExclusiveAccess also for notifying the listeners.
Sergey, could you review?
Comment 3 CDT Genie CLA 2011-05-02 04:23:01 EDT
*** cdt cvs genie on behalf of aleherbau ***
Bug 343948 - Shared ast is exposed for concurrent usage

[*] CReconcilingStrategy.java 1.28 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CReconcilingStrategy.java?root=Tools_Project&r1=1.27&r2=1.28
Comment 4 Sergey Prigogin CLA 2011-05-02 14:17:54 EDT
(In reply to comment #2)
The fix looks good. Thanks for fixing this.
Comment 5 Andrew Gvozdev CLA 2011-05-03 13:15:30 EDT
*** Bug 343175 has been marked as a duplicate of this bug. ***