-
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
Don't panic when failing to initialize incremental directory. #85698
Conversation
r? @estebank (rust-highfive has picked a reviewer for you, use r? to override) |
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.
Is there any way to create a regression test to fake a locking error on an incremental compilation?
I'm ok with the approach but am unclear on what the user will see if they hit this case going forward.
As for the options, my preference would be a warning if the user can actually do anything about the problem (even if it is just letting them know that maybe they want to disable incremental compilation), and if not and we can "gracefully" continue as if we had locked the file and plow forward without adverse effects, be silent like cargo is. That being said, I figure that we can't recover gracefully, so an error instead of an ICE is fine by me.
I don't think there is a reasonable way to simulate a lock failure on CI. I tested on macOS (using an smb share) and on Windows (using a WSL2 share), and it worked as expected. I couldn't get an error on Linux, but I didn't try too hard (smb, NFS, or ramdisks seemed like good candidates, but I couldn't get them to fail). The error looks something like this:
I added a test that verifies the general behavior when it fails to initialize the session directory by making a read-only directory. I'm not sure if that is worth it, but it should cover the general issue of it failing with ICE. I changed my mind about possibly ignoring lock failures. bjorn3 pointed out on zulip that concurrent access could lead to silent miscompilation. I'd like to stay conservative for now and leave it as an error. |
This comment has been minimized.
This comment has been minimized.
11587e0
to
834ec68
Compare
I'm ready to r+, but...
Could we change this to include an explanation or link on how to do either of those things? We could link to https://doc.rust-lang.org/cargo/reference/profiles.html#incremental and/or mention setting the env variable Either way, if you don't want to change the wording, r=me at your convenience. |
I added some extra text on how to resolve the error. It is a little wordy, but hopefully it should help (and hopefully this error is rare). It looks like this: @bors r=estebank |
📌 Commit e7411a2 has been approved by |
⌛ Testing commit e7411a2 with merge 29b3ce92b75637d52cd8b037bc03b0428e99e229... |
This comment has been minimized.
This comment has been minimized.
💔 Test failed - checks-actions |
@bors r=estebank Fixed the test so that it works correctly when run as root. |
📌 Commit 4c550bc has been approved by |
☀️ Test successful - checks-actions |
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 #44502 which was a major rework of how things work. Previously, things were simpler and the
load_dep_graph
function would emit an error and then continue on without panicking. With 1.22,load_dep_graph
was changed so that it assumes it can load the data without errors. Today, the problem is that it callsprepare_session_directory
and then immediately callsgarbage_collect_session_directories
which will panic since the session isIncrCompSession::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:
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: #49773, #59224, #66513, #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.