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: do not borrow shell across registry query #13647

Merged
merged 1 commit into from
Mar 26, 2024
Merged

Conversation

weihanglo
Copy link
Member

@weihanglo weihanglo commented Mar 26, 2024

What does this PR try to resolve?

Fixes #13646

How should we test and review this PR?

$ git clone https://github.com/taiki-e/easytime
$ cd easytime
$ cargo generate-lockfile
$ cargo update -Z minimal-versions --verbose

Additional information

A better and safer way is always calling gctx.shell() instead.

@rustbot
Copy link
Collaborator

rustbot commented Mar 26, 2024

r? @ehuss

rustbot has assigned @ehuss.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added Command-generate-lockfile S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 26, 2024
@weihanglo
Copy link
Member Author

Talked with @Muscraft and agree that it's safer to use gctx.shell() if there are other refactor moving code around. It is also unlikely to be the performance bottleneck.

Copy link
Member

@Muscraft Muscraft left a comment

Choose a reason for hiding this comment

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

Thanks for this! gctx.shell() is tricky, and I have shot myself in the foot with it many times (most recently when working on the linting system). I think removing bindings from it everywhere is a good idea.

Do you think it would be a good idea to add a test for this?

@weihanglo
Copy link
Member Author

Do you think it would be a good idea to add a test for this?

I lean toward not. Such a test cannot systematically prevent this kind of runtime borrow checking bug.

Copy link
Member

@Muscraft Muscraft left a comment

Choose a reason for hiding this comment

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

Feel free to r= me when CI passes if I don't get to it first

@Muscraft
Copy link
Member

@bors r+


I tested this change locally against https://github.com/taiki-e/easytime and it fixes the panic

@bors
Copy link
Contributor

bors commented Mar 26, 2024

📌 Commit 667803c has been approved by Muscraft

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 26, 2024
@bors
Copy link
Contributor

bors commented Mar 26, 2024

⌛ Testing commit 667803c with merge 499a61c...

@bors
Copy link
Contributor

bors commented Mar 26, 2024

☀️ Test successful - checks-actions
Approved by: Muscraft
Pushing 499a61c to master...

1 similar comment
@bors
Copy link
Contributor

bors commented Mar 26, 2024

☀️ Test successful - checks-actions
Approved by: Muscraft
Pushing 499a61c to master...

@bors bors merged commit 499a61c into rust-lang:master Mar 26, 2024
21 checks passed
@bors
Copy link
Contributor

bors commented Mar 26, 2024

👀 Test was successful, but fast-forwarding failed: 422 Changes must be made through a pull request.

bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 26, 2024
Update cargo

1 commits in a510712d05c6c98f987af24dd73cdfafee8922e6..499a61ce7a0fc6a72040084862a68b2603e770e8
2024-03-25 03:45:54 +0000 to 2024-03-26 04:17:04 +0000
- fix: do not borrow shell across registry query (rust-lang/cargo#13647)

r? ghost

<hr>

This update includes a fix for a panic within cargo that was noted in [cargo#13646](rust-lang/cargo#13646)
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 26, 2024
…rkingjubilee

Update cargo

5 commits in a510712d05c6c98f987af24dd73cdfafee8922e6..499a61ce7a0fc6a72040084862a68b2603e770e8
2024-03-25 03:45:54 +0000 to 2024-03-26 04:17:04 +0000
- fix: do not borrow shell across registry query (rust-lang/cargo#13647)
- Do not strip debuginfo by default for MSVC (rust-lang/cargo#13630)
- chore(deps): update msrv (rust-lang/cargo#13577)
- Fix doc collision for lib/bin with a dash in the inferred name. (rust-lang/cargo#13640)
- refactor: Make lint names snake_case (rust-lang/cargo#13635)

r? ghost
@rustbot rustbot added this to the 1.79.0 milestone Mar 26, 2024
@weihanglo weihanglo deleted the shell branch March 26, 2024 12:36
epage added a commit to epage/cargo that referenced this pull request Mar 26, 2024
This intentionally borrows from `RefCell`s before conditional code
to try to prevent regressions like rust-lang#13646 without exhaustively
covering every case that could hit these `BorrowMutError`s with
complicated tests.

I tested this by ensuring the registry code path panicked before
rebasing on top of rust-lang#13647.
Once I rebased, the panic went away.
weihanglo pushed a commit to weihanglo/cargo that referenced this pull request Mar 26, 2024
This intentionally borrows from `RefCell`s before conditional code
to try to prevent regressions like rust-lang#13646 without exhaustively
covering every case that could hit these `BorrowMutError`s with
complicated tests.

I tested this by ensuring the registry code path panicked before
rebasing on top of rust-lang#13647.
Once I rebased, the panic went away.

Co-authored-by: Ed Page <[email protected]>
bors added a commit that referenced this pull request Mar 26, 2024
test: Add asserts to catch BorrowMutError's

### What does this PR try to resolve?

This intentionally borrows from `RefCell`s before conditional code to try to prevent regressions like #13646 without exhaustively covering every case that could hit these `BorrowMutError`s with complicated tests.

### How should we test and review this PR?

I tested this by ensuring the registry code path panicked before rebasing on top of #13647.
Once I rebased, the panic went away.

### Additional information

Split off from #13649 to try to avoid appveyor
charmitro pushed a commit to charmitro/cargo that referenced this pull request Sep 13, 2024
This intentionally borrows from `RefCell`s before conditional code
to try to prevent regressions like rust-lang#13646 without exhaustively
covering every case that could hit these `BorrowMutError`s with
complicated tests.

I tested this by ensuring the registry code path panicked before
rebasing on top of rust-lang#13647.
Once I rebased, the panic went away.

Co-authored-by: Ed Page <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Command-generate-lockfile S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panic with "already borrowed: BorrowMutError" since nightly-2024-03-26
5 participants