Skip to content

rustc panic: "range start index 274090 out of range for slice of length 266240" #120065

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
samuela opened this issue Jan 17, 2024 · 7 comments
Closed
Assignees
Labels
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.

Comments

@samuela
Copy link

samuela commented Jan 17, 2024

Compiler panic:

❯ cargo check
    Checking reqwest v0.11.23
thread 'rustc' panicked at /build/rustc-1.73.0-src/compiler/rustc_serialize/src/opaque.rs:328:42:
range start index 274090 out of range for slice of length 266240
stack backtrace:
   0:     0x7f5120efd4ab - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h13e1a9b9ebeee924
   1:     0x7f5120f7f61c - core::fmt::write::h4241cb35c54123f4
   2:     0x7f5120f3473e - std::io::Write::write_fmt::hfe37cff7f3aa0e3d
   3:     0x7f5120efd285 - std::sys_common::backtrace::print::hc19a67331b3076ff
   4:     0x7f5120f1a143 - std::panicking::default_hook::{{closure}}::h10c691ff00f3f05c
   5:     0x7f5120f19dd6 - std::panicking::default_hook::h726a8dc68ee97020
   6:     0x7f511d62daca - std[d17fdd60fa3476a5]::panicking::update_hook::<alloc[88d12b3d6ad4a698]::boxed::Box<rustc_driver_impl[bf39fbbd91f1b3ae]::install_ice_hook::{closure#0}>>::{closure#0}
   7:     0x7f5120f1a9c7 - std::panicking::rust_panic_with_hook::hc77a4fa6bb2ac5c4
   8:     0x7f5120efd8c7 - std::panicking::begin_panic_handler::{{closure}}::h43aaf25fc9116c32
   9:     0x7f5120efd6b6 - std::sys_common::backtrace::__rust_end_short_backtrace::hc36652d4de1d92d2
  10:     0x7f5120f1a562 - rust_begin_unwind
  11:     0x7f5120ed08c3 - core::panicking::panic_fmt::h208bab87ed164649
  12:     0x7f5120ed0682 - core::slice::index::slice_start_index_len_fail::haf2cb5d55a0f466c
  13:     0x7f511ef6374a - <rustc_metadata[bafebeedf2d1a285]::rmeta::decoder::MetadataBlob>::get_header
  14:     0x7f511f04f734 - <rustc_metadata[bafebeedf2d1a285]::locator::CrateLocator>::extract_one
  15:     0x7f511f04e763 - <rustc_metadata[bafebeedf2d1a285]::locator::CrateLocator>::extract_lib
  16:     0x7f511f04bb10 - <rustc_metadata[bafebeedf2d1a285]::locator::CrateLocator>::maybe_load_library_crate
  17:     0x7f511ef524fb - <rustc_metadata[bafebeedf2d1a285]::creader::CrateLoader>::load
  18:     0x7f511ef4ea59 - <rustc_metadata[bafebeedf2d1a285]::creader::CrateLoader>::maybe_resolve_crate
  19:     0x7f511ef4df21 - <rustc_metadata[bafebeedf2d1a285]::creader::CrateLoader>::resolve_crate
  20:     0x7f511ef55008 - <rustc_metadata[bafebeedf2d1a285]::creader::CrateLoader>::process_path_extern
  21:     0x7f511e374b29 - <rustc_resolve[4fa02807f46aebac]::Resolver>::extern_prelude_get
  22:     0x7f511e377e21 - <rustc_resolve[4fa02807f46aebac]::Resolver>::early_resolve_ident_in_lexical_scope
  23:     0x7f511e376eeb - <rustc_resolve[4fa02807f46aebac]::Resolver>::resolve_ident_in_lexical_scope
  24:     0x7f511e354c53 - <rustc_resolve[4fa02807f46aebac]::Resolver>::resolve_path_with_ribs
  25:     0x7f511e32d06a - <rustc_resolve[4fa02807f46aebac]::late::LateResolutionVisitor>::smart_resolve_path_fragment
  26:     0x7f511e327f21 - <rustc_resolve[4fa02807f46aebac]::late::LateResolutionVisitor>::resolve_expr
  27:     0x7f511e3284cb - <rustc_resolve[4fa02807f46aebac]::late::LateResolutionVisitor>::resolve_expr
  28:     0x7f511e3284cb - <rustc_resolve[4fa02807f46aebac]::late::LateResolutionVisitor>::resolve_expr
  29:     0x7f511e2fb9a1 - <rustc_resolve[4fa02807f46aebac]::late::LateResolutionVisitor as rustc_ast[f37367120be07a2b]::visit::Visitor>::visit_local
  30:     0x7f511e2fb534 - <rustc_resolve[4fa02807f46aebac]::late::LateResolutionVisitor as rustc_ast[f37367120be07a2b]::visit::Visitor>::visit_block
  31:     0x7f511e3272be - <rustc_resolve[4fa02807f46aebac]::late::LateResolutionVisitor>::resolve_expr
  32:     0x7f511e2fb3d8 - <rustc_resolve[4fa02807f46aebac]::late::LateResolutionVisitor as rustc_ast[f37367120be07a2b]::visit::Visitor>::visit_block
  33:     0x7f511e327da0 - <rustc_resolve[4fa02807f46aebac]::late::LateResolutionVisitor>::resolve_expr
  34:     0x7f511e2faf06 - <rustc_resolve[4fa02807f46aebac]::late::LateResolutionVisitor as rustc_ast[f37367120be07a2b]::visit::Visitor>::visit_arm
  35:     0x7f511e3979ea - rustc_ast[f37367120be07a2b]::visit::walk_expr::<rustc_resolve[4fa02807f46aebac]::late::LateResolutionVisitor>
  36:     0x7f511e2fb3d8 - <rustc_resolve[4fa02807f46aebac]::late::LateResolutionVisitor as rustc_ast[f37367120be07a2b]::visit::Visitor>::visit_block
  37:     0x7f511e327da0 - <rustc_resolve[4fa02807f46aebac]::late::LateResolutionVisitor>::resolve_expr
  38:     0x7f511e2fb9a1 - <rustc_resolve[4fa02807f46aebac]::late::LateResolutionVisitor as rustc_ast[f37367120be07a2b]::visit::Visitor>::visit_local
  39:     0x7f511e2fb534 - <rustc_resolve[4fa02807f46aebac]::late::LateResolutionVisitor as rustc_ast[f37367120be07a2b]::visit::Visitor>::visit_block
  40:     0x7f511e302a6a - <rustc_resolve[4fa02807f46aebac]::late::LateResolutionVisitor as rustc_ast[f37367120be07a2b]::visit::Visitor>::visit_fn
  41:     0x7f511e38a200 - rustc_ast[f37367120be07a2b]::visit::walk_assoc_item::<rustc_resolve[4fa02807f46aebac]::late::LateResolutionVisitor>
  42:     0x7f511e3217e8 - <rustc_resolve[4fa02807f46aebac]::late::LateResolutionVisitor>::resolve_impl_item
  43:     0x7f511e3147ed - <rustc_resolve[4fa02807f46aebac]::late::LateResolutionVisitor>::resolve_item
  44:     0x7f511e2fad5d - <rustc_resolve[4fa02807f46aebac]::late::LateResolutionVisitor as rustc_ast[f37367120be07a2b]::visit::Visitor>::visit_item
  45:     0x7f511e39b2fb - rustc_ast[f37367120be07a2b]::visit::walk_item::<rustc_resolve[4fa02807f46aebac]::late::LateResolutionVisitor>
  46:     0x7f511e30b748 - <rustc_resolve[4fa02807f46aebac]::late::LateResolutionVisitor>::resolve_item
  47:     0x7f511e2fad5d - <rustc_resolve[4fa02807f46aebac]::late::LateResolutionVisitor as rustc_ast[f37367120be07a2b]::visit::Visitor>::visit_item
  48:     0x7f511e39b2fb - rustc_ast[f37367120be07a2b]::visit::walk_item::<rustc_resolve[4fa02807f46aebac]::late::LateResolutionVisitor>
  49:     0x7f511e30b748 - <rustc_resolve[4fa02807f46aebac]::late::LateResolutionVisitor>::resolve_item
  50:     0x7f511e2fad5d - <rustc_resolve[4fa02807f46aebac]::late::LateResolutionVisitor as rustc_ast[f37367120be07a2b]::visit::Visitor>::visit_item
  51:     0x7f511e360d0a - <rustc_resolve[4fa02807f46aebac]::Resolver>::late_resolve_crate
  52:     0x7f511e3b09eb - <rustc_session[82855e3803a411c8]::session::Session>::time::<(), <rustc_resolve[4fa02807f46aebac]::Resolver>::resolve_crate::{closure#0}>
  53:     0x7f511e371a6d - <rustc_resolve[4fa02807f46aebac]::Resolver>::resolve_crate
  54:     0x7f511d7ec56d - rustc_interface[aeb0894bc87efaa2]::passes::resolver_for_lowering
  55:     0x7f511e99bbfa - rustc_query_impl[afe32a768d34a902]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[afe32a768d34a902]::query_impl::resolver_for_lowering::dynamic_query::{closure#2}::{closure#0}, rustc_middle[5bee4b31b9e360c2]::query::erase::Erased<[u8; 8usize]>>
  56:     0x7f511ea96b68 - <rustc_query_impl[afe32a768d34a902]::query_impl::resolver_for_lowering::dynamic_query::{closure#2} as core[8382c35236c8b6bd]::ops::function::FnOnce<(rustc_middle[5bee4b31b9e360c2]::ty::context::TyCtxt, ())>>::call_once
  57:     0x7f511ebcb985 - rustc_query_system[f5ae987f4fd54ec9]::query::plumbing::try_execute_query::<rustc_query_impl[afe32a768d34a902]::DynamicConfig<rustc_query_system[f5ae987f4fd54ec9]::query::caches::SingleCache<rustc_middle[5bee4b31b9e360c2]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[afe32a768d34a902]::plumbing::QueryCtxt, false>
  58:     0x7f511ea9a84d - rustc_query_impl[afe32a768d34a902]::query_impl::resolver_for_lowering::get_query_non_incr::__rust_end_short_backtrace
  59:     0x7f511d5e622c - <rustc_middle[5bee4b31b9e360c2]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[bf39fbbd91f1b3ae]::run_compiler::{closure#1}::{closure#2}::{closure#4}, &rustc_data_structures[49bd39e3a5064985]::steal::Steal<(rustc_middle[5bee4b31b9e360c2]::ty::ResolverAstLowering, alloc[88d12b3d6ad4a698]::rc::Rc<rustc_ast[f37367120be07a2b]::ast::Crate>)>>
  60:     0x7f511d61217e - rustc_span[36dbb4002cdf15a1]::set_source_map::<core[8382c35236c8b6bd]::result::Result<(), rustc_span[36dbb4002cdf15a1]::ErrorGuaranteed>, rustc_interface[aeb0894bc87efaa2]::interface::run_compiler<core[8382c35236c8b6bd]::result::Result<(), rustc_span[36dbb4002cdf15a1]::ErrorGuaranteed>, rustc_driver_impl[bf39fbbd91f1b3ae]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  61:     0x7f511d64ac4a - std[d17fdd60fa3476a5]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[aeb0894bc87efaa2]::util::run_in_thread_pool_with_globals<rustc_interface[aeb0894bc87efaa2]::interface::run_compiler<core[8382c35236c8b6bd]::result::Result<(), rustc_span[36dbb4002cdf15a1]::ErrorGuaranteed>, rustc_driver_impl[bf39fbbd91f1b3ae]::run_compiler::{closure#1}>::{closure#0}, core[8382c35236c8b6bd]::result::Result<(), rustc_span[36dbb4002cdf15a1]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8382c35236c8b6bd]::result::Result<(), rustc_span[36dbb4002cdf15a1]::ErrorGuaranteed>>
  62:     0x7f511d62e02b - <<std[d17fdd60fa3476a5]::thread::Builder>::spawn_unchecked_<rustc_interface[aeb0894bc87efaa2]::util::run_in_thread_pool_with_globals<rustc_interface[aeb0894bc87efaa2]::interface::run_compiler<core[8382c35236c8b6bd]::result::Result<(), rustc_span[36dbb4002cdf15a1]::ErrorGuaranteed>, rustc_driver_impl[bf39fbbd91f1b3ae]::run_compiler::{closure#1}>::{closure#0}, core[8382c35236c8b6bd]::result::Result<(), rustc_span[36dbb4002cdf15a1]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8382c35236c8b6bd]::result::Result<(), rustc_span[36dbb4002cdf15a1]::ErrorGuaranteed>>::{closure#1} as core[8382c35236c8b6bd]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  63:     0x7f5120f2a395 - std::sys::unix::thread::Thread::new::thread_start::hd89eec8fc730285b
  64:     0x7f511cca3084 - start_thread
  65:     0x7f511cd2560c - __GI___clone3
  66:                0x0 - <unknown>

error: 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.73.0 (cc66ad468 2023-10-03) (built from a source tarball) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2

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

query stack during panic:
#0 [resolver_for_lowering] getting the resolver for lowering
end of query stack
error: could not compile `reqwest` (lib)
@samuela samuela 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 Jan 17, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 17, 2024
@samuela
Copy link
Author

samuela commented Jan 17, 2024

I'll add that cargo build works fine it's just cargo check that produces this panic.

@Teapot4195
Copy link
Contributor

Can you please provide the rust code (or project) that causes this issue? As well as rustc version.

@samuela
Copy link
Author

samuela commented Jan 17, 2024

Here's my rustc version:

❯ rustc --version      
rustc 1.73.0 (cc66ad468 2023-10-03) (built from a source tarball)

AFAIU it's failing in Checking reqwest v0.11.23 and not in my code. I can try to extract a minimal repro, but can't make any promises

@Teapot4195
Copy link
Contributor

It does look like it is failing in reqwest, but I can't seem to reproduce it on 1.{72,73,74}. If you were to clone the reqwest library from git and compile that, does it also crash? (also probably should have noticed the rustc version from the backtrace, oops).

@clubby789
Copy link
Contributor

Does this reproduce after a cargo clean, or if you update to stable/use the latest nightly?

@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 2, 2024
@saethlin
Copy link
Member

I've been trying to work on a problem where running out of disk produces a broken rmeta file that crashes subsequent compilations. This issue report looks like that situation, which should be fixed by the combination of #117301 and #119510. I'll check back on this issue later.

@saethlin saethlin self-assigned this Feb 11, 2024
@saethlin
Copy link
Member

I think the root cause of this issue was rustc incorrectly handling/reporting I/O errors. I've landed a number of PRs to address the problem; the most recent of those is #119510 which is now part of the latest stable toolchain, 1.77. Therefore, even though I have not reproduced exactly what you've reported here, I'm going to close this because I am reasonably confident that this bug is now fixed on stable.

Of course it is possible that I am wrong and the bug you've reported here is not fixed. If you happen to run into problems like this in 1.77 or later please do not hesitate to open a new issue.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
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.
Projects
None yet
Development

No branches or pull requests

5 participants