-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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] Don't panic if decoding the cache fails #49364
Conversation
r? @cramertj (rust_highfive has picked a reviewer for you, use r? to override) |
Not sure who to give this to, but definitely not me, so r? @michaelwoerister |
|
||
MaybeAsync::Async(std::thread::spawn(move || { | ||
time_ext(time_passes, None, "background load prev dep-graph", move || { | ||
panic::catch_unwind(load).unwrap_or_else( |
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.
Do we need to catch the unwind? Can't we just handle this on thread.join() since we're paying that cost anyway?
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.
That's a good idea! I will do some testing and see if that works.
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.
Yes, that's a good suggestion.
MaybeAsync::Async(std::thread::spawn(move || { | ||
time_ext(time_passes, None, "background load prev dep-graph", move || { | ||
panic::catch_unwind(load).unwrap_or_else( | ||
|_| LoadResult::Error { message: "could not decode incremental cache".into() }) |
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.
Please emit the actual panic via a debug! or even info! call, so we can figure out what's going on without needing to rebuild the compiler.
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.
I couldn't figure out a way to do this. I tried doing formatting the error into the message with format!("could not decode incremental cache: {:?}", e)
but that just printed "could not decode incremental cache: Any"
.
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.
Maybe someone for @rust-lang/libs knows how to do this best?
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.
There's currently no easy way to get out the message of a Box<Any>
unfortunately, but we also tend to recommend against using catch_unwind
for error handling like this and would instead recommend returning an Err
all the way up (which can then be printed)
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.
The panic handler for the thread is still running so the compiler output looks like this:
Compiling webrender v0.57.0 (file:///Users/wesley/code/rust/temp3/webrender/webrender)
thread '<unnamed>' panicked at 'internal error: entered unreachable code', librustc/dep_graph/dep_node.rs:124:34
note: Run with `RUST_BACKTRACE=1` for a backtrace.
warning: could not decode incremental cache
Thanks for the PR, @wesleywiser! I'll take a look shortly. |
Thanks, @wesleywiser! @bors r+ |
📌 Commit 369f34c has been approved by |
If the cached data can't be loaded from disk, just issue a warning to the user so they know why compilation is taking longer than usual but don't fail the entire compilation since we can recover by ignorning the on disk cache. In the same way, if the disk cache can't be deserialized (because it has been corrupted for some reason), report the issue as a warning and continue without failing the compilation. `Decodable::decode()` tends to panic with various errors like "entered unreachable code" or "index out of range" if the input data is corrupted. Work around this by catching panics from the `decode()` calls when joining the thread and continuing without the cached data. Fixes rust-lang#48847
369f34c
to
49fd71b
Compare
Rebased |
@bors r+ |
📌 Commit 49fd71b has been approved by |
…e, r=michaelwoerister [incremental] Don't panic if decoding the cache fails If the cached data can't be loaded from disk, just issue a warning to the user so they know why compilation is taking longer than usual but don't fail the entire compilation since we can recover by ignorning the on disk cache. In the same way, if the disk cache can't be deserialized (because it has been corrupted for some reason), report the issue as a warning and continue without failing the compilation. `Decodable::decode()` tends to panic with various errors like "entered unreachable code" or "index out of range" if the input data is corrupted. Work around this by catching panics from the `decode()` calls and continuing without the cached data. Fixes rust-lang#48847
Thanks for fixing this! |
If the cached data can't be loaded from disk, just issue a warning to
the user so they know why compilation is taking longer than usual but
don't fail the entire compilation since we can recover by ignorning the
on disk cache.
In the same way, if the disk cache can't be deserialized (because it has
been corrupted for some reason), report the issue as a warning and
continue without failing the compilation.
Decodable::decode()
tends topanic with various errors like "entered unreachable code" or "index out
of range" if the input data is corrupted. Work around this by catching
panics from the
decode()
calls and continuing without the cached data.Fixes #48847