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

internal compiler error: failed to process buffered lint here #81531

Closed
tmandry opened this issue Jan 29, 2021 · 7 comments · Fixed by #81541 or #81699
Closed

internal compiler error: failed to process buffered lint here #81531

tmandry opened this issue Jan 29, 2021 · 7 comments · Fixed by #81541 or #81699
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@tmandry
Copy link
Member

tmandry commented Jan 29, 2021

Code

I don't have a minimal example yet, but here's the code. Sample:

    async fn report_check_interval(&mut self, install_source: InstallSource) {
        let now = self.time_source.now();

        match self.context.schedule.last_update_check_time {
            Some(PartialComplexTime::Wall(t)) => match now.wall_duration_since(t) {
                Ok(interval) => self.report_metrics(Metrics::UpdateCheckInterval {
                    interval,
                    clock: ClockType::Wall,
                    install_source,
                }),
                Err(e) => warn!("Last check time is in the future: {}", e),  // <-- ICE
            },

            Some(PartialComplexTime::Complex(t)) => match now.mono.checked_duration_since(t.mono) {
                Some(interval) => self.report_metrics(Metrics::UpdateCheckInterval {
                    interval,
                    clock: ClockType::Monotonic,
                    install_source,
                }),
                None => error!("Monotonic time in the past"),  // <-- ICE
            },

            _ => {}
        }

        self.context.schedule.last_update_check_time = now.into();
    }

The ICE happens on the warn! and error! macros, which are both from the log crate.

Meta

This began with commit 74500b9.

Error output

error: internal compiler error: failed to process buffered lint here
   --> ../../src/sys/pkg/lib/omaha-client/src/state_machine.rs:539:27
    |
539 |                 Err(e) => warn!("Last check time is in the future: {}", e),
    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: delayed at /b/s/w/ir/x/w/rust/compiler/rustc_lint/src/early.rs:384:18
    = note: this error: internal compiler error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: internal compiler error: failed to process buffered lint here
   --> ../../src/sys/pkg/lib/omaha-client/src/state_machine.rs:552:25
    |
552 |                 None => error!("Monotonic time in the past"),
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: delayed at /b/s/w/ir/x/w/rust/compiler/rustc_lint/src/early.rs:384:18
    = note: this error: internal compiler error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: internal compiler error: failed to process buffered lint here
   --> ../../src/sys/pkg/lib/omaha-client/src/state_machine.rs:997:27
    |
997 |                 Err(e) => warn!("Update first seen time is in the future: {}", e),
    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: delayed at /b/s/w/ir/x/w/rust/compiler/rustc_lint/src/early.rs:384:18
    = note: this error: internal compiler error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
Backtrace

 RUST_BACKTRACE=1 ../../prebuilt/third_party/rust/linux-x64/bin/rustc --color=always --crate-name omaha_client ../../src/sys/pkg/lib/omaha-client/src/lib.rs --crate-type rlib --emit=dep-info=obj/sr…
error: internal compiler error: failed to process buffered lint here
   --> ../../src/sys/pkg/lib/omaha-client/src/state_machine.rs:539:27
    |
539 |                 Err(e) => warn!("Last check time is in the future: {}", e),
    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: delayed at /b/s/w/ir/x/w/rust/compiler/rustc_lint/src/early.rs:384:18
    = note: this error: internal compiler error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: internal compiler error: failed to process buffered lint here
   --> ../../src/sys/pkg/lib/omaha-client/src/state_machine.rs:552:25
    |
552 |                 None => error!("Monotonic time in the past"),
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: delayed at /b/s/w/ir/x/w/rust/compiler/rustc_lint/src/early.rs:384:18
    = note: this error: internal compiler error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: internal compiler error: failed to process buffered lint here
   --> ../../src/sys/pkg/lib/omaha-client/src/state_machine.rs:997:27
    |
997 |                 Err(e) => warn!("Update first seen time is in the future: {}", e),
    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: delayed at /b/s/w/ir/x/w/rust/compiler/rustc_lint/src/early.rs:384:18
    = note: this error: internal compiler error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:974:13
stack backtrace:
   0: rust_begin_unwind
             at /b/s/w/ir/x/w/rust/library/std/src/panicking.rs:493:5
   1: std::panicking::begin_panic_fmt
             at /b/s/w/ir/x/w/rust/library/std/src/panicking.rs:435:5
   2: rustc_errors::HandlerInner::flush_delayed
   3: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
   4: core::ptr::drop_in_place<rustc_session::parse::ParseSess>
   5: <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop
   6: core::ptr::drop_in_place<rustc_interface::interface::Compiler>
   7: rustc_span::with_source_map
   8: rustc_interface::interface::create_compiler_and_run
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.51.0-nightly (b12290861 2021-01-29) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z dep-info-omit-d-target -Z allow-features= -Z panic_abort_tests -C linker=/b/s/w/ir/x/w/fuchsia/prebuilt/third_party/clang/linux-x64/bin/lld -C link-arg=--sysroot=gen/zircon…

query stack during panic:
end of query stack

@tmandry tmandry added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Jan 29, 2021
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jan 29, 2021
@Aaron1011 Aaron1011 self-assigned this Jan 29, 2021
@camelid

This comment has been minimized.

@tmandry

This comment has been minimized.

@Aaron1011
Copy link
Member

Minimized:

macro_rules! foo {
    () => { true; }
}

async fn func() {
    let _ = foo!();
}

fn main() {}

Caused by #79819

@Aaron1011
Copy link
Member

When we run DefCollector on the AST, we create a definition for the desugared closure body inside an async fn:

// For async functions, we need to create their inner defs inside of a
// closure to match their desugared representation. Besides that,
// we must mirror everything that `visit::walk_fn` below does.
self.visit_fn_header(&sig.header);
visit::walk_fn_decl(self, &sig.decl);
let closure_def = self.create_def(closure_id, DefPathData::ClosureExpr, span);
self.with_parent(closure_def, |this| walk_list!(this, visit_block, body));

As a result, the invocation_parents entry for our macro call will have the DefId of the desugared closure. However, this desugared closure does not actually exist in the AST (it is created during lowering), so we will never check for lints with its NodeId when we emit buffered early lints.

@jethrogb
Copy link
Contributor

jethrogb commented Feb 1, 2021

Nightly has been broken for 3 days, if there's disagreement on how to fix the issue, can we revert #79819 while the fix is being worked on?

@Aaron1011
Copy link
Member

Aaron1011 commented Feb 2, 2021

This will be fixed by PR #81541

bors added a commit to rust-lang-ci/rust that referenced this issue Feb 2, 2021
…ochenkov

Fix early lints inside an async desugaring

Fixes rust-lang#81531

When we buffer an early lint for a macro invocation,
we need to determine which NodeId to take the lint level from.
Currently, we use the NodeId of the closest def parent. However, if
the macro invocation is inside the desugared closure from an `async fn`
or async closure, that NodeId does not actually exist in the AST.

This commit uses the parent of a desugared closure when computing
`lint_node_id`, which is something that actually exists in the AST (an
`async fn` or async closure).
@bors bors closed this as completed in a74b2fb Feb 2, 2021
@jethrogb
Copy link
Contributor

jethrogb commented Feb 3, 2021

I'm still hitting this bug with the latest nightly.

use futures::prelude::*;
use failure::bail;

fn main() {
    let _: std::pin::Pin<Box<dyn futures::Future<Output = Result<(), failure::Error>>>> = (async move {
        bail!("")
    }).boxed_local();
}

@bors bors closed this as completed in 6ad11e2 Feb 3, 2021
@camelid camelid removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Feb 3, 2021
timothee-haudebourg added a commit to timothee-haudebourg/json-ld that referenced this issue Feb 5, 2021
Add semicolon after warn

Work around error appearing in Rust nightly 2021-01-30 (rust-lang/rust#81531, rust-lang/rust#81724)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
6 participants