-
Notifications
You must be signed in to change notification settings - Fork 370
fix: restructure hanging lock logic #11115
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
base: master
Are you sure you want to change the base?
Conversation
When `try_lock_exclusive` succeeds, it acquires the lock. As a result, the lock is no longer available and `lock_exclusive` blocks indefinitely.
|
Thank you for your contribution to the Noir language. Please do not force push to this branch after the Noir team have started review of this PR. Doing so will only delay us merging your PR as we will need to start the review process from scratch. Thanks for your understanding. |
|
Thank you for opening this PR. Have you actually encountered a deadlock due to this issue? Can you create a bug ticket to replicate it?
If this were true, we should get this problem every time we try to compile anything. I assume that the way it should work is that if the same process or thread calls I tried changing it the following way, and it still worked: println!("locking {lock_name}...");
fs2::FileExt::try_lock_exclusive(&file)?;
fs2::FileExt::lock_exclusive(&file)?;
fs2::FileExt::try_lock_exclusive(&file)?;
fs2::FileExt::lock_exclusive(&file)?;
println!("locked {lock_name}"); |
I encountered a deadlock when running it on a Windows machine. It was previously working fine on my Mac machine. I assume operating systems have different strictness for acquiring the lock again. |
|
Ah, right, thank you for creating the ticket, that gives more context, great to know that it didn't work on Windows. Do you mind updating the PR to handle all cases? |
|
Updated the PR to handle all cases |
aakoshh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you for fixing all of them 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thank you!
|
I don't know if you saw the error, but |
When
try_lock_exclusivesucceeds, it acquires the lock. As a result, the lock is no longer available andlock_exclusiveblocks indefinitely.Description
Problem
Resolves #11137
Summary
Additional Context
User Documentation
Check one:
PR Checklist
cargo fmton default settings.