-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
incremental compilation: could not create session directory lock file: No locks available (os error 37) #49773
Comments
This is an issue we are currently seeing on linux-sparc64 as well [1]:
I have not yet figured out where this comes from. The same rust version worked fine in the past. |
NFS does not support locking files very well, I guess. It would be good if there was some way to make Cargo put the incremental folder somewhere else (into cc @rust-lang/cargo |
Although the original report mentions NFS, we're not using NFS for the sparc64 buildds; the two issues have similar but different error messages ("No locks available" vs "No such process") so they could well be different problems. |
@jrtc27, yes, sounds like a different root cause. |
In Cargo we disable file locking whenever NFS is detected, although that may not work well for rustc as it's semi-reasonable to expect Cargo to not be run in parallel much on one system but rustc probably is being executed in parallel by Cargo at least. An alternative to moving the incremental directory is moving the locks for the incremental directory. I've considered this for Cargo where we actually want to enable file locking on NFS directories. That'd require more intrusive support in rustc, though. |
If anyone wants to reproduce this problem, there are sparc64 porterboxes available in the gcc compile farm, both running Solaris and Linux. Any open source developer can apply for an account: |
Is this on a file system that should support locks in general?
As long as we don't want to support two different machines working on the same NFS share simultaneously (which we don't really do anyway), we could indeed just allocate that lock files in |
It's a standard off-the-shelf installation of Debian on ext4. Nothing special. There is no NFS or anything involved and it affects sparc64 machines with the same configuration as comparable x86_64 machines. |
Interesting. That's unexpected. |
You can test it yourself on the Linux/sparc64 porterbox available in the gcc compile farm. It's a rather fast machine. |
I've requested an account. Thanks for the tip! |
I have root privileges on the sparc64 machine (but not the others), so I can install additional packages if required. |
@michaelwoerister Did you have any success getting an account in the gcc compile farm? |
@glaubitz Yes, I have an account. I haven't gotten around to actually using it though. |
@michaelwoerister @alexcrichton @karcherm has had a look at the Rust sources and he found the problem rather quickly. Rust is hard-wiring the constants for the fnctls from glibc assuming they are constant across which they are not. Compare: and:
Rust is trying to call "Set Lock" and uses function control number 6. But that's "F_SETOWN" on sparc64 which expects a PID as a parameter which is why the error message is "No such process". |
I get this when compiling files stored on WSL2, but running cargo on windows. So running on windows and compiling on this path:
|
Ditto from @tpn-station ... I likewise have source on WSL2 (Ubuntu-20.04 w/ native Kernel) filesystem with Ubuntu's root FS mounted as drive "N:" in Windows. To Windows it looks like a network drive. My Rust project is configured for Windows build (as opposed to running CLion in Ubuntu). I also tried avoiding the "N:" drive-letter mapping and specifying source files directly as "'\\wsl$\Ubuntu-20.04\home..." and hit the same error. |
Same issue on WSL 2 as above. |
Hi, I think I am seeing a related error. I was trying to build the hello world example from https://rust-cli.github.io/book/tutorial/setup.html and when issuing cargo run, get:
I am on a MacOS computer running 10.15.4 and the current working directory where I ran "cargo" run" is an smb mount to a network-based file server (Ubuntu):
|
Current workaround for Windows compiling a project in WSL2: # powershell
$env:CARGO_INCREMENTAL=0; cargo build see #66513 (comment) |
I'm facing the very same issue (Rust 1.48.0, Mac -> SMB), documented here: Both of these two workarounds are valid on Mac OSX:
Sorry, if i commented/documented on the wrong issue ... |
…tebank Don't panic when failing to initialize incremental directory. This removes a panic when rustc fails to initialize the incremental directory. This can commonly happen on various filesystems that don't support locking (often various network filesystems). Panics can be confusing and scary, and there are already plenty of issues reporting this. This has been panicking since 1.22 due to I think rust-lang#44502 which was a major rework of how things work. Previously, things were simpler and the [`load_dep_graph`](https://github.com/rust-lang/rust/blob/1.21.0/src/librustc_incremental/persist/load.rs#L43-L65) function would emit an error and then continue on without panicking. With 1.22, [`load_dep_graph`](https://github.com/rust-lang/rust/blob/1.22.0/src/librustc_incremental/persist/load.rs#L44) was changed so that it assumes it can load the data without errors. Today, the problem is that it calls [`prepare_session_directory`](https://github.com/rust-lang/rust/blob/fbf1b1a7193cda17008ab590e06ad28d9924023b/compiler/rustc_interface/src/passes.rs#L175-L179) and then immediately calls `garbage_collect_session_directories` which will panic since the session is `IncrCompSession::NotInitialized`. The solution here is to have `prepare_session_directory` return an error that must be handled so that compilation stops if it fails. Some other options: * Ignore directory lock failures. * Print a warning on directory lock failure, but otherwise continue with incremental enabled. * Print a warning on directory lock failure, and disable incremental. * Provide a different locking mechanism. Cargo ignores lock errors if locking is not supported, so that would be a precedent for the first option. These options would require quite a bit more changes, but I'm happy to entertain any of them, as I think they all have valid justifications. There is more discussion on the many issues where this is reported: rust-lang#49773, rust-lang#59224, rust-lang#66513, rust-lang#76251. I'm not sure if this can be considered closing any of those, though, since I think there is some value in discussing if there is a way to avoid the error altogether. But I think it would make sense to at least close all but one to consolidate them.
regarding SMB mounts on macOS: I checked ages ago and flock seems to work fine with SMB mounts it's specifically F_SETLK with fcntl that doesn't work. I believe this means that the Linux code path would work fine for macOS but either way a fallback would be nice. |
How is rustc deciding that locks aren't working? Is it just a heuristic? Because my NFS4 mount on macOS does support locks and they work. If it's a heuristic can it be overruled? |
This may or may not be useful, but for possible future Googlers.... I keep my dev folder on a TrueNAS server and access via an NFS share. Ended up with this issue after moving from Core to Scale. The fix was to turn on both "Enable NFSv4" and "NFSv3 ownership model for NFSv4" in the NFS service settings. |
I was unable to incrementally compile using cargo build.
I had added the rand dependency to the toml file, per the advice of the Guessing Game exercise in Rust Programming Language (Second Edition).
Before this particular error, I had just finished setting up a synced folder with NFS on my vagrant box (ubuntu 16.04) where rust was installed. There is some issue using the default vagrant shared folder setup with rust.
I tried this code:
I expected to see this happen:
compile
Instead, this happened:
rustc --version --verbose
:Backtrace:
The text was updated successfully, but these errors were encountered: