`./x check` being killed (by rust-analyzer) may leave `.git/index.lock` file
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 85/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- rust
- Domain
- build-system
Research direction
The problematic code path is traced in the stacktrace: git subprocesses are spawned from src/bootstrap/src/build_helper/git.rs (run_git_diff_index, changes_since), called via check_path_modifications in src/bootstrap/src/core/config/config.rs and detect_llvm_freshness in src/bootstrap/src/core/build_steps/llvm.rs. Review these locations to add logic that cleans up .git/index.lock if the x.py process is killed while the git subprocess is running. Verify the fix by triggering a check kill during git execution and confirming no lock file remains.
Written by the indexing model from the issue text.
Description
Summary
The python x.py check runs git update-index --refresh -q (indirectly in detect_llvm_freshness), which crates .git/index.lock. Normally wen git finishes the index.lock will be deleted.
In rust-analyzer flycheck.rs, it seems that when the previous python x.py check is still running, if check is triggered again, then the previous x process will be killed. If it kills the x process when the git subprocess is running, git will be killed and it will left .git/index.lock file.
When there is a leftover .git/index.lock I cannot do things like commit or push, so I have to manually delete the index.lock.
(I am using Windows, so maybe git runs slower, then it's more likely to trigger than other machines.)
Command used
VSCode rust-analyzer runs python x.py check --json-output --build-dir build-rust-analyzer
Expected behaviour
Not leaving .git/index.lock
Actual behaviour
Leaves .git/index.lock when no git process is running
Bootstrap configuration (bootstrap.toml)
profile = "compiler" # Includes one of the default files in src/bootstrap/defaults
change-id = 154508
Operating system
Windows 11
HEAD
Closest official commit is 28b6e691688c15cef4c60d9044274e7b84397870
Additional context
In bootstrap, the detect_llvm_freshness indirectly calls git update-index --refresh -q. Stacktrace:
7: build_helper::git::run_git_diff_index::<build_helper::git::changes_since::{closure#0}, core::result::Result<alloc::vec::Vec<std::path::PathBuf>, alloc::string::String>>
8: build_helper::git::changes_since
9: build_helper::git::check_path_modifications
10: bootstrap::core::config::config::impl$0::check_path_modifications::closure$0
at .\src\bootstrap\src\core\config\config.rs:1873
11: std::collections::hash::map::impl$72::or_insert_with::closure$0<alloc::vec::Vec<ref$<str$>,alloc::alloc::Global>,enum2$<build_helper::git::PathFreshness>,alloc::alloc::Global,bootstrap::core::config::config::impl$0::check_path_modifications::closure_env$0>
at /rustc/cbae9b4cae2b108f6a3d18cfe6075714bb739463/library\std\src\collections\hash\map.rs:2540
12: std::collections::hash::map::Entry::or_try_insert_with<alloc::vec::Vec<ref$<str$>,alloc::alloc::Global>,enum2$<build_helper::git::PathFreshness>,alloc::alloc::Global,std::collections::hash::map::impl$72::or_insert_with::closure_env$0<alloc::vec::Vec<ref$<s
at /rustc/cbae9b4cae2b108f6a3d18cfe6075714bb739463/library\std\src\collections\hash\map.rs:2575
13: std::collections::hash::map::Entry::or_insert_with<alloc::vec::Vec<ref$<str$>,alloc::alloc::Global>,enum2$<build_helper::git::PathFreshness>,alloc::alloc::Global,bootstrap::core::config::config::impl$0::check_path_modifications::closure_env$0>
at /rustc/cbae9b4cae2b108f6a3d18cfe6075714bb739463/library\std\src\collections\hash\map.rs:2540
14: bootstrap::core::config::config::Config::check_path_modifications
at .\src\bootstrap\src\core\config\config.rs:1872
15: bootstrap::core::build_steps::llvm::detect_llvm_freshness
at .\src\bootstrap\src\core\build_steps\llvm.rs:327
16: bootstrap::core::config::config::Config::maybe_download_ci_llvm
at .\src\bootstrap\src\core\download.rs:281
17: bootstrap::core::build_steps::llvm::try_download_ci_llvm
at .\src\bootstrap\src\core\build_steps\llvm.rs:281
18: bootstrap::core::build_steps::llvm::impl$4::run
at .\src\bootstrap\src\core\build_steps\llvm.rs:410
19: bootstrap::core::builder::Builder::ensure<bootstrap::core::build_steps::llvm::LlvmFromCi>
at .\src\bootstrap\src\core\builder\mod.rs:1643
20: bootstrap::core::build_steps::llvm::prebuilt_llvm_output
at .\src\bootstrap\src\core\build_steps\llvm.rs:175
21: bootstrap::core::build_steps::llvm::get_llvm_build_status
at .\src\bootstrap\src\core\build_steps\llvm.rs:195
22: bootstrap::core::build_steps::dist::maybe_install_llvm_target
at .\src\bootstrap\src\core\build_steps\dist.rs:2610
23: bootstrap::core::build_steps::compile::impl$15::run
at .\src\bootstrap\src\core\build_steps\compile.rs:1962
24: bootstrap::core::builder::Builder::ensure<bootstrap::core::build_steps::compile::Sysroot>
at .\src\bootstrap\src\core\builder\mod.rs:1643
25: bootstrap::core::builder::Builder::sysroot
at .\src\bootstrap\src\core\builder\mod.rs:1339
26: bootstrap::core::builder::impl$12::run
at .\src\bootstrap\src\core\builder\mod.rs:730
(line numbers may not match because bootstrap code was changed for debugging. The issue occurs in unchanged bootstrap.)
Build Log
<log>
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 17.3k
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 544
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rust-lang/rust
-
needs-triage relnotes relnotes-needs-review relnotes-tracking-issue T-compiler T-libs
Difficulty 1/5 Under an hour Newbie friendliness 85/100
rust-lang/rust#163875 · 1 comment ·
Maintainers usually reply within 1 day
-
I-prioritize needs-triage regression-from-stable-to-beta T-lang
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
rust-lang/rust#163830 · 1 comment ·
Maintainers usually reply within 1 day
-
relnotes-tracking-issue T-release
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
rust-lang/rust#163811 · 5 comments ·
Maintainers usually reply within 1 day
-
Regression 1.98 → 1.99: `thread_local!` destructors no longer run at thread exit on `wasm32-wasip1-threads`Possibly taken @maxdexh claimed this 2 days ago. OpenA-thread-locals C-bug O-wasi P-medium regression-from-stable-to-stable T-libs
Difficulty 1/5 Under an hour Newbie friendliness 85/100
rust-lang/rust#163748 · 3 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
needs-triage relnotes relnotes-needs-review relnotes-tracking-issue T-compiler T-libs T-rustdoc
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
Similar issues
-
documentation
Difficulty 1/5 Under an hour Newbie friendliness 90/100
fastrevmd-lab/rustmistmcp#161 ·
-
arch-audit refactor
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
SocketDev/socket-patch#1011 ·
Maintainers usually reply within 1 day
-
bug user-priority/P2
Difficulty 1/5 Under an hour Newbie friendliness 92/100
Maintainers usually reply within 1 day
-
opencode: an unanswered --version probe launches opencode 2 without per-session service isolationOpen
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
security-advisory
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
MinBZK/regelrecht#1686 ·
Maintainers usually reply within 1 day