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

fix deadlock between require_lock and package callbacks #43936

Merged
merged 1 commit into from
Jan 26, 2022
Merged

Conversation

JeffBezanson
Copy link
Member

Fix the deadlock described in #43339 (comment)

Also fix one place where we were acquiring require_lock twice (which is ok since it's reentrant, but not preferred).

@JeffBezanson JeffBezanson added the packages Package management and loading label Jan 25, 2022
@tkf
Copy link
Member

tkf commented Jan 26, 2022

Also fix one place where we were acquiring require_lock twice (which is ok since it's reentrant, but not preferred).

Isn't the strategy you've implemented in this PR actually relies on this? IIUC, the intention of run_package_callbacks is to release the require_lock "completely" so that require_lock is not acquired by the time the callbacks are called.

@vchuravy vchuravy added this to the 1.8 milestone Jan 26, 2022
@Keno Keno merged commit 15df9c0 into master Jan 26, 2022
@Keno Keno deleted the jb/pkgdeadlock branch January 26, 2022 04:21
""")
Base.compilecache(Base.PkgId("$(Test4_module)"))
push!(Base.package_callbacks, _->(notify(E); lock(L) do; end))
# should not hang here
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we perhaps should have an assert that the lock state is unlocked, so that it cannot hang?

@JeffBezanson
Copy link
Member Author

Isn't the strategy you've implemented in this PR actually relies on this?

I don't understand --- if it's locked twice, the unlock is not sufficient, so we need it to be locked only once at a time.

@tkf
Copy link
Member

tkf commented Jan 26, 2022

By "this", I mean the patch introducing _require_prelocked. I should've avoided using the word "this". I meant that, since run_package_callbacks requires to turn require_lock to unlocked state, we can't lock require_lock multiple times in require methods. Without _require_prelocked, the call chain like require(into::Module, mod::Symbol) -> require(uuidkey::PkgId) -> run_package_callbacks would have called the callbacks while require_lock is still being locked.

To put it in another way, your comment in the OP sounded like the change introducing _require_prelocked was optional. I thought it was a requirement.

LilithHafner pushed a commit to LilithHafner/julia that referenced this pull request Feb 22, 2022
LilithHafner pushed a commit to LilithHafner/julia that referenced this pull request Mar 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packages Package management and loading
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants