Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly scope lock use in xde_detach #545

Merged
merged 2 commits into from
Jun 4, 2024
Merged

Correctly scope lock use in xde_detach #545

merged 2 commits into from
Jun 4, 2024

Commits on Jun 3, 2024

  1. Correctly scope lock use in xde_detach

    As part of #485, we need to *inspect* the contents of the shared
    `XdeState` before taking ownership and dropping its contents. However, I
    had created a scenario where:
    
    - The lock is acquired, based on a reference derived from the dev
      info ptr (`dip`),
    - Ownership of the contents of `dip` is taken using `Box::new_raw`,
    - These contents (`XdeState`) are freed,
    - The `MutexGuard` pointing into the `XdeState` is dropped, and attempts
      to unlock a freed mutex.
    
    This PR scopes the `&XdeState` and the derived `MutexGuard` in an inner
    block, correcting this drop order issue by forcing the free to happen at
    the end of a lexica scope.
    
    Fixes #543.
    FelixMcFelix committed Jun 3, 2024
    Configuration menu
    Copy the full SHA
    07590ac View commit details
    Browse the repository at this point in the history
  2. Call destroy methods on KMutex, KRWLock.

    Required a little creativity to satisfy borrowck around
    `KMutex::into_inner`, but we got there.
    FelixMcFelix committed Jun 3, 2024
    Configuration menu
    Copy the full SHA
    3e698ed View commit details
    Browse the repository at this point in the history