Skip to content

[BUG]: Remove the reader refresh data race in FUSE read-after-write [LiAuto] #1396

Description

@yangcx000

Describe the bug

Concurrent reads on one read/write handle can simultaneously observe a changed writer version, flush and reopen the reader, and call RawPtr<FuseReader>::replace without synchronization. Another task may concurrently call path or read through the same pointer.

This is Rust undefined behavior and can cause double free, use-after-free, heap corruption, or crashes.

To Reproduce

  1. Open one file handle for reading and writing.
  2. Perform a write that advances write_ver.
  3. Issue concurrent reads on the same handle with multiple FUSE tasks.
  4. Allow both reads to enter the reopen branch.

Expected behavior

Reader state must use safe ownership. Version check, writer flush, reader reopen, installation, and version update must form a synchronized per-handle state transition.

OS Version (please complete the following information):

  • Linux
  • Curvine branch: current main
  • Component: curvine-fuse/src/fs/state/backend_handle.rs

Additional context

Add deterministic single-flight reopen tests, refresh-failure tests, concurrent read/write stress tests, and read-path performance measurements.

Dependency: the stable release/handle cleanup work should land first to reduce lifecycle conflicts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions