Bug 560187 - Threading issue in ProjectDescription
Summary: Threading issue in ProjectDescription
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 3.8.2   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-Resources-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-02-16 04:34 EST by Marc M CLA
Modified: 2020-02-16 12:49 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marc M CLA 2020-02-16 04:34:55 EST
I got an IO exception while adding natures to a project:
Caused by: org.eclipse.core.internal.resources.ResourceException: File not found: Foo/.project.
	at org.eclipse.core.internal.localstore.FileSystemResourceManager.read(FileSystemResourceManager.java:834)
	at org.eclipse.core.internal.resources.File.getContents(File.java:275)
	at org.eclipse.core.internal.localstore.FileSystemResourceManager.descriptionChanged(FileSystemResourceManager.java:382)
	at org.eclipse.core.internal.localstore.FileSystemResourceManager.internalWrite(FileSystemResourceManager.java:651)
	at org.eclipse.core.internal.resources.Project.writeDescription(Project.java:1383)
	at org.eclipse.core.internal.resources.Project.setDescription(Project.java:1275)
	at org.eclipse.core.internal.resources.Project.setDescription(Project.java:1298)



Apparently the static isWriting, isReading flags in the ProjectDescription are responsible to note on whether any thread reads or writes a project description at the moment.

	protected static boolean isReading = false;

	//flags to indicate when we are in the middle of reading or writing a
	// workspace description
	//these can be static because only one description can be read at once.
	protected static boolean isWriting = false;


However, since the fields are not marked volatile, written changes to the the fields may not be propagated to others threads, so that two threads can write concurrently nontheless.

But even then it seems that two or more threads may write descriptions concurrently, since no checks or waiting-loop exists in Project.writeDescription before starting writing.
Comment 1 Andrey Loskutov CLA 2020-02-16 12:49:09 EST
I have no code at hand right now, but I wonder if the writer is supposed to run with a workspace lock? But static global variables is a nonsense anyway in multiple ways.

Is the exception you get reproducible, and can you attach the code snippet causing it?