Skip to content

server: Unsynchronized derived data provider deletion #245

@siwei-zhang-work

Description

@siwei-zhang-work

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.

  1. Thread 1 sends a request to create Provider 1. The request completes successfully.

  2. Thread 1 immediately sends a request to delete Provider 1.

  3. The 1DataProviderManager#removeDataProvider()1 method begins executing for Provider 1. It successfully gets an iterator for the collection of providers associated with the trace.

  4. 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.

  1. The removeDataProvider() method in Thread 1 resumes. Its iterator is now stale and its internal state is inconsistent with the underlying collection.

  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions