Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Possible race condition in cdt can result in clients accessing stale IASTTranslationUnit data.


Consider the following scenario.  
A CDT Client (extender)  listens to CElementDelta and does some processing on receiving it by retrieving the IASTTranslationUnit of the element.

When an C++ element is changed, say new field has been added to a Class. two events are generated on save, cdt emits CElementDelta and eclipse resource emits resource change event.  There is a possibility that Clients get stale AST from CDOM.getInstance().getTranslationUnit(IFile). This because CodeReaderCache of SavedCodeReaderFactory  updates only when it receives resource change event. Since the events has been send from two different object, it is possible that  clients receive CElementDelta before the resource change message reaches the cdt CodeReaderCache, in such case client will be processing  based on stale copy of code. This causes the problem.  

We have been facing this issue randomly causing source files to get corrupted.

May be we should clear the CodeReaderCache of  SavedResourceReaderFactor when the buffer is saved. This should solve the problem.

Created bug:  #154056  [ https://bugs.eclipse.org/bugs/show_bug.cgi?id=154056 ]

Thanks and Regards,
Janees


Back to the top