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

Reduce mutex poisoning #515

Closed
asomers opened this issue Sep 13, 2023 · 0 comments · Fixed by #527
Closed

Reduce mutex poisoning #515

asomers opened this issue Sep 13, 2023 · 0 comments · Fixed by #527
Labels
enhancement New feature or request

Comments

@asomers
Copy link
Owner

asomers commented Sep 13, 2023

Mocked static methods contain an internal Mutex . If a test case panics while accessing it (for example, by violating a .times() constraint, or by explicitly panicing in the .returning function), then the Mutex will be poisoned, and all future test cases trying to use the same static method will fail with PoisonError.

::mockall::lazy_static! {

::mockall::lazy_static! {

But the Expectations object guarded by this Mutex gets cleared on Drop anyway. So we may as well clear any poison at the same time. That requires a nightly compiler.
https://doc.rust-lang.org/std/sync/struct.Mutex.html#method.clear_poison

@asomers asomers added the enhancement New feature or request label Sep 13, 2023
asomers added a commit that referenced this issue Dec 9, 2023
If a test case panics while holding a static method's internal Mutex
locked, for example by violating a times() constraint, then clear the
Mutex's poison during Drop.  We're going to delete all of its
Expectations anyway, so there's no data to be poisoned.

Requires nightly.

Fixes #515
asomers added a commit that referenced this issue Dec 9, 2023
If a test case panics while holding a static method's internal Mutex
locked, for example by violating a times() constraint, then clear the
Mutex's poison during Drop.  We're going to delete all of its
Expectations anyway, so there's no data to be poisoned.

Requires nightly.

Fixes #515
asomers added a commit that referenced this issue Jan 14, 2024
If a test case panics while holding a static method's internal Mutex
locked, for example by violating a times() constraint, then clear the
Mutex's poison during Drop.  We're going to delete all of its
Expectations anyway, so there's no data to be poisoned.

Requires nightly.

Fixes #515
asomers added a commit that referenced this issue Feb 24, 2024
If a test case panics while holding a static method's internal Mutex
locked, for example by violating a times() constraint, then clear the
Mutex's poison during Drop.  We're going to delete all of its
Expectations anyway, so there's no data to be poisoned.

Requires nightly.

Fixes #515
asomers added a commit that referenced this issue Feb 24, 2024
If a test case panics while holding a static method's internal Mutex
locked, for example by violating a times() constraint, then clear the
Mutex's poison during Drop.  We're going to delete all of its
Expectations anyway, so there's no data to be poisoned.

Requires nightly.

Fixes #515
asomers added a commit that referenced this issue Feb 24, 2024
If a test case panics while holding a static method's internal Mutex
locked, for example by violating a times() constraint, then clear the
Mutex's poison during Drop.  We're going to delete all of its
Expectations anyway, so there's no data to be poisoned.

Requires nightly.

Fixes #515
asomers added a commit that referenced this issue Feb 24, 2024
If a test case panics while holding a static method's internal Mutex
locked, for example by violating a times() constraint, then clear the
Mutex's poison during Drop.  We're going to delete all of its
Expectations anyway, so there's no data to be poisoned.

Requires nightly.

Fixes #515
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant