Spdx-Java-Library icon indicating copy to clipboard operation
Spdx-Java-Library copied to clipboard

Deadlock in ListedLicenseWebStore

Open goneall opened this issue 1 year ago • 1 comments

When fetching the license, a deadlock occurs at:

https://github.com/spdx/Spdx-Java-Library/blob/bb41916630c1eaf5ff5ec71d59cfbd6d303eeebc/src/main/java/org/spdx/storage/listedlicense/SpdxListedLicenseModelStore.java#L352

due to a readlock being held in the call at: https://github.com/spdx/Spdx-Java-Library/blob/bb41916630c1eaf5ff5ec71d59cfbd6d303eeebc/src/main/java/org/spdx/storage/listedlicense/SpdxListedLicenseModelStore.java#L305

Stack trace:

Thread [main] (Suspended)	
	owns: JsonLDDeserializer  (id=40)	
	Unsafe.park(boolean, long) line: not available [native method]	
	LockSupport.park(Object) line: 194	
	ReentrantReadWriteLock$NonfairSync(AbstractQueuedSynchronizer).parkAndCheckInterrupt() line: 885	
	ReentrantReadWriteLock$NonfairSync(AbstractQueuedSynchronizer).acquireQueued(AbstractQueuedSynchronizer$Node, int) line: 917	
	ReentrantReadWriteLock$NonfairSync(AbstractQueuedSynchronizer).acquire(int) line: 1240	
	ReentrantReadWriteLock$WriteLock.lock() line: 959	
	SpdxListedLicenseWebStore(SpdxListedLicenseModelStore).fetchLicenseJson(String) line: 352	
	SpdxListedLicenseWebStore(SpdxListedLicenseModelStore).getPropertyValueDescriptors(String) line: 308	
	SpdxV3ListedLicenseModelStore.getPropertyValueDescriptors(String) line: 138	
	ModelCopyManager.copyCompatible(IModelStore, String, IModelStore, TypedValue, String, String) line: 300	
	ModelCopyManager.copy(IModelStore, String, IModelStore, String, String, String) line: 258	
	ModelCopyManager.copy(IModelStore, IModelStore, String, String, String) line: 423	
	JsonLDDeserializer.jsonStringToSpdxObject(JsonNode, String, Map<String,TypedValue>) line: 405	
	JsonLDDeserializer.jsonStringToStoredValue(String, JsonNode, String, Map<String,TypedValue>) line: 363	
	JsonLDDeserializer.toStoredObject(String, JsonNode, String, Map<String,String>, Map<String,TypedValue>) line: 341	
	JsonLDDeserializer.deserializeCoreObject(JsonNode, String, Map<String,String>, Map<String,TypedValue>) line: 241	
	JsonLDDeserializer.deserializeGraph(JsonNode) line: 129	
	JsonLDStore.deSerialize(InputStream, boolean) line: 149	
	JsonLDStore.deSerialize(InputStream, boolean) line: 52	
	SpdxToolsHelper.deserializeFile(ISerializableModelStore, File) line: 300	
	SpdxToolsHelper.readDocumentFromFileV3(ISerializableModelStore, File) line: 341	
	SpdxToolsHelper.readDocumentFromFile(ISerializableModelStore, File) line: 356	
	Verify.verify(String, SerFileType) line: 155	
	Verify.main(String[]) line: 88	

goneall avatar Sep 09 '24 01:09 goneall

The simplest solution would be to just hold write locks instead of readlocks, but that would negatively impact concurrency.

goneall avatar Sep 09 '24 01:09 goneall