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

Bug 343948

Summary: Shared ast is exposed for concurrent usage
Product: [Tools] CDT Reporter: Markus Schorn <mschorn.eclipse>
Component: cdt-editorAssignee: Anton Leherbauer <aleherb+eclipse>
Status: RESOLVED FIXED QA Contact: Anton Leherbauer <aleherb+eclipse>
Severity: major    
Priority: P3 CC: angvoz.dev, cdtdoug, eclipse.sprigogin
Version: 8.0Flags: eclipse.sprigogin: review+
Target Milestone: 8.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:

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. ***