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

Bug 319245

Summary: Thread safety issue reading .cproject XML
Product: [Tools] CDT Reporter: James Blackburn <jamesblackburn+eclipse>
Component: cdt-coreAssignee: James Blackburn <jamesblackburn+eclipse>
Status: RESOLVED FIXED QA Contact: Doug Schaefer <cdtdoug>
Severity: major    
Priority: P3    
Version: 7.0   
Target Milestone: 7.0.1   
Hardware: PC   
OS: Linux-GTK   
Whiteboard:
Attachments:
Description Flags
bt
none
patch 1
jamesblackburn+eclipse: iplog-
patch 2 jamesblackburn+eclipse: iplog-

Description James Blackburn CLA 2010-07-08 05:39:54 EDT
Created attachment 173754 [details]
bt

The project description is unlocked before all the XML has been completely de-serialized.  Listeners which hook off the loaded event, may fetch XMLStorageElements from the project description which will cause problems as the DOM tree is not thread-safe.

Backtrace attached.
Comment 1 James Blackburn CLA 2010-07-09 07:20:31 EDT
Xerxes DOM is not thread-safe for reads -- all access to the DOM need to be synchronized:
http://xerces.apache.org/xerces2-j/faq-dom.html#faq-1

Our ICStorageElement tree is back by the XML, so it amazing we haven't seen more exceptions like the above...
Comment 2 James Blackburn CLA 2010-07-09 09:47:06 EDT
Created attachment 173857 [details]
patch 1

Simple patch which synchronizes XML-backed ICStorageElement DOM access on the backing Element's Document.   Aims to make the tree thread-safe without perturbing the existing (de)-serialization locking flow.

Tests continue to pass. Will stress test it here for a bit.
Comment 3 James Blackburn CLA 2010-07-09 10:13:50 EDT
Created attachment 173863 [details]
patch 2

Missed a couple places.
Comment 4 James Blackburn CLA 2010-07-13 10:49:18 EDT
Fixed on HEAD.
Daily regression tests that were hitting this issue here are working reliably now.
Comment 5 CDT Genie CLA 2010-07-13 11:38:16 EDT
*** cdt cvs genie on behalf of jblackburn ***
Bug 319245 -  Thread safety issue reading .cproject XML

[*] XmlStorageElement.java 1.3 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlStorageElement.java?root=Tools_Project&r1=1.2&r2=1.3
[*] XmlStorage.java 1.4 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlStorage.java?root=Tools_Project&r1=1.3&r2=1.4
[*] XmlProjectDescriptionStorage.java 1.10 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlProjectDescriptionStorage.java?root=Tools_Project&r1=1.9&r2=1.10

[*] XmlStorageElement.java 1.2.2.1 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlStorageElement.java?root=Tools_Project&r1=1.2&r2=1.2.2.1
[*] XmlStorage.java 1.3.2.1 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlStorage.java?root=Tools_Project&r1=1.3&r2=1.3.2.1
[*] XmlProjectDescriptionStorage.java 1.8.2.1 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlProjectDescriptionStorage.java?root=Tools_Project&r1=1.8&r2=1.8.2.1