Skip to content

test: pin the ProceedUnlocked registry test-and-set against regression #330

Closed

Description

@adityamukho

Summary

The LockOutcome::ProceedUnlocked arm in src/storage/backend/file.rs performs an atomic test-and-set against the OPEN_PATHS registry. Nothing tests it directly.

Background

That arm runs only on a filesystem that cannot lock at all, where the caller has set OpenOptions::allow_unlocked(true). There is no kernel lock behind it, so the process-global registry is the only thing preventing two handles on one file — which is the #304 two-page-tables corruption.

It originally checked and inserted under two separate lock acquisitions. Two threads could both observe "absent", both insert, and both proceed. That was found in final review and fixed by collapsing to a single critical section using HashSet::insert's return value, with a poisoned mutex failing closed.

Why a test is wanted

The fix is currently guaranteed by code inspection alone. A future refactor could reintroduce the two-step pattern with nothing failing. This is a corruption path, so inspection is a thin guarantee.

The obstacle is that reaching the arm requires File::try_lock to return TryLockError::Error, which needs a genuinely lock-incapable mount — not something a tempdir-based test can force. classify is already a pure function so the enum mapping is unit-tested; the untested part is the registry interaction inside open_with.

Task

  • Add a test that races the OPEN_PATHS test-and-set directly, via a test-only seam, rather than through a real unlockable filesystem
  • Assert the second concurrent caller is refused rather than admitted

Related: #324 covers testing the real NFS behaviour of this path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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