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

Compiler error #103624

Closed
vkavoun opened this issue Oct 27, 2022 · 3 comments · Fixed by #103641
Closed

Compiler error #103624

vkavoun opened this issue Oct 27, 2022 · 3 comments · Fixed by #103641
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@vkavoun
Copy link

vkavoun commented Oct 27, 2022

Code

#[tokio::main]
async fn main() {
    util::bootstrap();

    let config = config::get_config().await;
    let task_factory = Arc::new(tasks::TaskFactory::new(config).await);
    &task_factory.create_async_jobs().await;
}

pub struct TaskFactory {
    config: Arc<Mutex<Config>>,
    sched: Arc<JobScheduler>,
    job_map: HashMap<JobKey, Uuid>,
}

impl TaskFactory {
    pub async fn new(config: Arc<Mutex<Config>>) -> Self {
        TaskFactory {
            config,
            sched: Arc::new(JobScheduler::new().await.unwrap()),
            job_map: HashMap::new(),
        }
    }

    pub async fn create_async_jobs(&mut self) {
        let fs_job = Job::new("0 15 6,8,10 * Mar,Jun Fri 2017", |_uuid, _lock| {
            let _ = Box::new(async move {
                println!("{:?} Hi I ran", chrono::Utc::now());
            });
        })
        .unwrap();

        let fs_id = self.sched.add(fs_job).await;
        
        self.job_map
            .insert(JobKey::FsWatcher, fs_id.unwrap().to_owned());

        tokio::spawn(self.sched.start());
    }
}

Meta

rustc --version --verbose:

rustc 1.66.0-nightly (1898c34e9 2022-10-26)
binary: rustc
commit-hash: 1898c34e923bad763e723c68dd9f23a09f9eb0fc
commit-date: 2022-10-26
host: x86_64-apple-darwin
release: 1.66.0-nightly
LLVM version: 15.0.2

Error output

thread 'rustc' panicked at 'index out of bounds: the len is 4 but the index is 21', compiler/rustc_middle/src/mir/mod.rs:484:27
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic_bounds_check
   3: <rustc_middle::mir::Body>::stmt_at
   4: <rustc_borrowck::MirBorrowckCtxt>::report_region_errors
   5: rustc_borrowck::do_mir_borrowck
   6: rustc_borrowck::mir_borrowck
   7: <rustc_borrowck::provide::{closure#0} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId)>>::call_once
   8: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId, &rustc_middle::mir::query::BorrowCheckResult>
   9: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalDefId, &rustc_middle::mir::query::BorrowCheckResult>>
  10: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::mir_borrowck, rustc_query_impl::plumbing::QueryCtxt>
  11: rustc_hir_analysis::collect::type_of::find_opaque_ty_constraints_for_rpit
  12: rustc_hir_analysis::collect::type_of::type_of
  13: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_span::def_id::DefId, rustc_middle::ty::Ty>
  14: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::DefId, rustc_middle::ty::Ty>>
  15: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::type_of, rustc_query_impl::plumbing::QueryCtxt>
  16: rustc_hir_analysis::check::check::check_item_type
  17: rustc_hir_analysis::check::check::check_mod_item_types
  18: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId, ()>
  19: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalDefId, ()>>
  20: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::check_mod_item_types, rustc_query_impl::plumbing::QueryCtxt>
  21: <rustc_middle::hir::map::Map>::for_each_module::<rustc_hir_analysis::check_crate::{closure#6}::{closure#0}>
  22: <rustc_session::session::Session>::time::<(), rustc_hir_analysis::check_crate::{closure#6}>
  23: rustc_hir_analysis::check_crate
  24: rustc_interface::passes::analysis
  25: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, (), core::result::Result<(), rustc_errors::ErrorGuaranteed>>
  26: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), core::result::Result<(), rustc_errors::ErrorGuaranteed>>>
  27: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
  28: <rustc_interface::passes::QueryContext>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#3}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
  29: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}::{closure#1}>
  30: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
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.66.0-nightly (1898c34e9 2022-10-26) running on x86_64-apple-darwin

note: compiler flags: --crate-type bin -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [mir_borrowck] borrow-checking `tasks::<impl at synch/src/tasks.rs:23:1: 23:17>::create_async_jobs`
#1 [type_of] computing type of `tasks::<impl at synch/src/tasks.rs:23:1: 23:17>::create_async_jobs::{opaque#0}`
#2 [check_mod_item_types] checking item types in module `tasks`
#3 [analysis] running analysis passes on this crate
end of query stack
error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: `InferCtxt` incorrectly tainted by errors
  |
  = note: delayed at compiler/rustc_infer/src/infer/mod.rs:1256:27

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_borrowck/src/region_infer/opaque_types.rs:225:29

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1553:13
stack backtrace:
   0:        0x101ba0872 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h8383c0d931dac499
   1:        0x101bf871a - core::fmt::write::h5c9e1cc689d98f86
   2:        0x101b9283c - std::io::Write::write_fmt::h54b1470a45435db6
   3:        0x101ba063a - std::sys_common::backtrace::print::h680264161637fe54
   4:        0x101ba3a46 - std::panicking::default_hook::{{closure}}::h0483df2036046fcc
   5:        0x101ba3797 - std::panicking::default_hook::hf1f18e1c03ad04ce
   6:        0x10a7f173d - rustc_driver[9bf29971085fb7bf]::DEFAULT_HOOK::{closure#0}::{closure#0}
   7:        0x101ba4241 - std::panicking::rust_panic_with_hook::h4e7d455a2bb5fad8
   8:        0x10f1d7ed7 - std[648fbc9a209824e3]::panicking::begin_panic::<rustc_errors[1873bd03a3adff3d]::ExplicitBug>::{closure#0}
   9:        0x10f1d5f09 - std[648fbc9a209824e3]::sys_common::backtrace::__rust_end_short_backtrace::<std[648fbc9a209824e3]::panicking::begin_panic<rustc_errors[1873bd03a3adff3d]::ExplicitBug>::{closure#0}, !>
  10:        0x10f59c939 - std[648fbc9a209824e3]::panicking::begin_panic::<rustc_errors[1873bd03a3adff3d]::ExplicitBug>
  11:        0x10f1c6ec9 - std[648fbc9a209824e3]::panic::panic_any::<rustc_errors[1873bd03a3adff3d]::ExplicitBug>
  12:        0x10f1cf18e - <rustc_errors[1873bd03a3adff3d]::HandlerInner>::flush_delayed::<alloc[ab4f8790a070fa97]::vec::Vec<rustc_errors[1873bd03a3adff3d]::diagnostic::Diagnostic>, &str>
  13:        0x10f1caff9 - <rustc_errors[1873bd03a3adff3d]::HandlerInner as core[88283cb3fe7bc080]::ops::drop::Drop>::drop
  14:        0x10a77648a - core[88283cb3fe7bc080]::ptr::drop_in_place::<rustc_session[e6307d959f83850c]::parse::ParseSess>
  15:        0x10a777c0b - core[88283cb3fe7bc080]::ptr::drop_in_place::<rustc_session[e6307d959f83850c]::session::Session>
  16:        0x10a7da31e - core[88283cb3fe7bc080]::ptr::drop_in_place::<rustc_interface[12398f78c94f0bee]::interface::Compiler>
  17:        0x10a7c4dcf - rustc_span[37bf332db493ba96]::with_source_map::<core[88283cb3fe7bc080]::result::Result<(), rustc_errors[1873bd03a3adff3d]::ErrorGuaranteed>, rustc_interface[12398f78c94f0bee]::interface::run_compiler<core[88283cb3fe7bc080]::result::Result<(), rustc_errors[1873bd03a3adff3d]::ErrorGuaranteed>, rustc_driver[9bf29971085fb7bf]::run_compiler::{closure#1}>::{closure#0}::{closure#1}>
  18:        0x10a7b42cc - <scoped_tls[c56e5754288267f2]::ScopedKey<rustc_span[37bf332db493ba96]::SessionGlobals>>::set::<rustc_interface[12398f78c94f0bee]::interface::run_compiler<core[88283cb3fe7bc080]::result::Result<(), rustc_errors[1873bd03a3adff3d]::ErrorGuaranteed>, rustc_driver[9bf29971085fb7bf]::run_compiler::{closure#1}>::{closure#0}, core[88283cb3fe7bc080]::result::Result<(), rustc_errors[1873bd03a3adff3d]::ErrorGuaranteed>>
  19:        0x10a78400a - std[648fbc9a209824e3]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[12398f78c94f0bee]::util::run_in_thread_pool_with_globals<rustc_interface[12398f78c94f0bee]::interface::run_compiler<core[88283cb3fe7bc080]::result::Result<(), rustc_errors[1873bd03a3adff3d]::ErrorGuaranteed>, rustc_driver[9bf29971085fb7bf]::run_compiler::{closure#1}>::{closure#0}, core[88283cb3fe7bc080]::result::Result<(), rustc_errors[1873bd03a3adff3d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[88283cb3fe7bc080]::result::Result<(), rustc_errors[1873bd03a3adff3d]::ErrorGuaranteed>>
  20:        0x10a76a02b - <<std[648fbc9a209824e3]::thread::Builder>::spawn_unchecked_<rustc_interface[12398f78c94f0bee]::util::run_in_thread_pool_with_globals<rustc_interface[12398f78c94f0bee]::interface::run_compiler<core[88283cb3fe7bc080]::result::Result<(), rustc_errors[1873bd03a3adff3d]::ErrorGuaranteed>, rustc_driver[9bf29971085fb7bf]::run_compiler::{closure#1}>::{closure#0}, core[88283cb3fe7bc080]::result::Result<(), rustc_errors[1873bd03a3adff3d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[88283cb3fe7bc080]::result::Result<(), rustc_errors[1873bd03a3adff3d]::ErrorGuaranteed>>::{closure#1} as core[88283cb3fe7bc080]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  21:        0x101bad357 - std::sys::unix::thread::Thread::new::thread_start::hf9f65e800e7fef93
  22:     0x7ff818206259 - __pthread_start

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.66.0-nightly (1898c34e9 2022-10-26) running on x86_64-apple-darwin

note: compiler flags: --crate-type bin -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
thread panicked while panicking. aborting.
warning: `synch` (bin "synch") generated 1 warning
error: could not compile `synch`; 1 warning emitted

Caused by:
  process didn't exit successfully: `rustc --crate-name synch --edition=2021 synch/src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C metadata=e8248b5923a5d720 -C extra-filename=-e8248b5923a5d720 --out-dir /Users/dframe/workspace/rust/wasynch/target/debug/deps -C incremental=/Users/dframe/workspace/rust/wasynch/target/debug/incremental -L dependency=/Users/dframe/workspace/rust/wasynch/target/debug/deps --extern axum=/Users/dframe/workspace/rust/wasynch/target/debug/deps/libaxum-5b075a599251ec28.rlib --extern chrono=/Users/dframe/workspace/rust/wasynch/target/debug/deps/libchrono-569a48d1531b8625.rlib --extern serde=/Users/dframe/workspace/rust/wasynch/target/debug/deps/libserde-05acf80525069f3c.rlib --extern serde_json=/Users/dframe/workspace/rust/wasynch/target/debug/deps/libserde_json-44aad93b62192287.rlib --extern tokio=/Users/dframe/workspace/rust/wasynch/target/debug/deps/libtokio-a3a12b8cda967c06.rlib --extern tokio_cron_scheduler=/Users/dframe/workspace/rust/wasynch/target/debug/deps/libtokio_cron_scheduler-1e5079cd3bfa189d.rlib --extern util=/Users/dframe/workspace/rust/wasynch/target/debug/deps/libutil-9f9741b4c8a2c942.rlib --extern uuid=/Users/dframe/workspace/rust/wasynch/target/debug/deps/libuuid-b37f6432c2a2f39c.rlib` (signal: 6, SIGABRT: process abort signal)
Backtrace

<backtrace>

@vkavoun vkavoun added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 27, 2022
@agostbiro
Copy link

I've managed to repro with this on 1.66.0-nightly (2022-10-25 bed4ad65bf7a1cef39e3)

use tokio::task;

struct StructA {
    b: StructB,
}

impl StructA {
    async fn foo(&self) {
        let bar = self.b.bar().await;
        task::spawn_blocking(move || {
            self.b;
        });
    }
}

struct StructB {}

impl StructB {
    async fn bar(&self) -> Option<u8> {
        None
    }
}

Error output:

thread '<unnamed>' panicked at 'index out of bounds: the len is 4 but the index is 14', compiler/rustc_middle/src/mir/mod.rs:484:27

@TaKO8Ki TaKO8Ki added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Oct 27, 2022
@agostbiro
Copy link

Hi @TaKO8Ki thanks for looking into this issue. I saw you added the "E-needs-mcve" label. Wondering how to improve this example?

@compiler-errors
Copy link
Member

@agostbiro that's a sufficient example, I can look into it.

@compiler-errors compiler-errors self-assigned this Oct 27, 2022
@compiler-errors compiler-errors added S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue and removed E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Oct 27, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Oct 28, 2022
…gillot

Don't carry MIR location in `ConstraintCategory::CallArgument`

It turns out that `ConstraintCategory::CallArgument` cannot just carry a MIR location in it, since we may bubble them up to totally different MIR bodies.

So instead, revert the commit a6b5f95, and instead just erase regions from the original `Option<Ty<'tcx>>` that it carried, so that it doesn't ICE with the changes in rust-lang#103220.

Best reviewed in parts -- the first is just a revert, and the second is where the meaningful changes happen.

Fixes rust-lang#103624
@bors bors closed this as completed in 84663ce Oct 28, 2022
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) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants