-
Notifications
You must be signed in to change notification settings - Fork 23
Description
Bug Description:
There is a race condition in DataProviderManager caused by inconsistent synchronization when accessing the shared fInstances map. The removeDataProvider() method is not synchronized, allowing it to run concurrently with synchronized methods that add new data providers.
This can lead to a scenario where a request to delete one data provider (Provider 1) incorrectly deletes a completely different provider (Provider 2) that was created at the same time by another thread. This results in data loss and leaves the application in an inconsistent state.
Steps to Reproduce:
The bug can be reproduced by simulating two parallel client threads operating on the same trace, provider 1 and 2 has different ids.
-
Thread 1 sends a request to create Provider 1. The request completes successfully.
-
Thread 1 immediately sends a request to delete Provider 1.
-
The 1DataProviderManager#removeDataProvider()1 method begins executing for Provider 1. It successfully gets an iterator for the collection of providers associated with the trace.
-
Thread 2, running in parallel, sends a request to create Provider 2.
The Race Condition: The create request from Thread 2 acquires its lock and modifies the same collection that Thread 1 is currently iterating over.
-
The
removeDataProvider()method in Thread 1 resumes. Its iterator is now stale and its internal state is inconsistent with the underlying collection. -
When
iter.remove()is finally called in Thread 1, it operates on this corrupt state and incorrectly removes the newly added Provider 2.
Additional Information
- Operating System: Linux.
- Trace Compass Version: Current master.