Skip to content

ICE in rustc_borrowck/src/region_infer #114907

Closed
@sjeohp

Description

@sjeohp

Code

use tungstenite::handshake::server::{Response, ErrorResponse};
fn accept_connection(stream: TcpStream, config: rustls::server::ServerConfig) -> Result<Socket> {
    let mut conn = rustls::server::ServerConnection::new(std::sync::Arc::new(config.clone()))?;
    let tlsstream = rustls::StreamOwned::new(conn, stream.try_clone()?);
    if let Ok(ws) = match tungstenite::accept_hdr_with_config(tlsstream, |req, res| -> std::result::Result<Response, ErrorResponse> {
        let callback = |req, res| -> std::result::Result<tungstenite::handshake::server::Response, tungstenite::handshake::server::ErrorResponse> {
            dbg!(&req);
            dbg!(&res);
            Ok(res)
        }; 
        if let Ok(ws) = match tungstenite::accept_hdr_with_config(tlsstream, callback, None) {

Does not happen with this callback:

    let callback = |req: &Request, res| {
        dbg!(req);
         dbg!(&res);
         Ok(res)
    };  

Meta

rustc --version --verbose:

rustc 1.71.1 (eb26296b5 2023-08-03)
binary: rustc
commit-hash: eb26296b556cef10fb713a38f3d16b9886080f26
commit-date: 2023-08-03
host: aarch64-apple-darwin
release: 1.71.1
LLVM version: 16.0.5

Error output

thread 'rustc' panicked at 'IndexMap: key not found', compiler/rustc_borrowck/src/region_infer/mod.rs:2243:9
stack backtrace:
   0:        0x1050b2cc0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hb75be2413dd8ceb3
   1:        0x105101a64 - core::fmt::write::h95d50546e769656f
   2:        0x1050a8e2c - std::io::Write::write_fmt::hce019ca594763835
   3:        0x1050b2b14 - std::sys_common::backtrace::print::hae7307dcada41b2a
   4:        0x1050b5578 - std::panicking::default_hook::{{closure}}::h30c41986d637ef23
   5:        0x1050b5380 - std::panicking::default_hook::h81d03189ef2e7e78
   6:        0x10d567f98 - rustc_driver_impl[21827c9a287a9f15]::install_ice_hook::{closure#0}
   7:        0x1050b5c2c - std::panicking::rust_panic_with_hook::he8360f4d28da55fc
   8:        0x1050b5a0c - std::panicking::begin_panic_handler::{{closure}}::he9e07d605072520f
   9:        0x1050b30a0 - std::sys_common::backtrace::__rust_end_short_backtrace::he03bf52f9c1eb73a
  10:        0x1050b5780 - _rust_begin_unwind
  11:        0x10512c9e0 - core::panicking::panic_fmt::ha5f5ca2311fff2ad
  12:        0x10512c9ac - core::option::expect_failed::hd3d75bda03d1d99e
  13:        0x11032336c - <rustc_borrowck[d3fa50dc65dee768]::MirBorrowckCtxt>::report_region_errors
  14:        0x1103347b4 - rustc_borrowck[d3fa50dc65dee768]::do_mir_borrowck
  15:        0x110327a84 - rustc_borrowck[d3fa50dc65dee768]::mir_borrowck
  16:        0x11083d904 - rustc_query_impl[465c999071b35b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[465c999071b35b]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a39402582bfd677]::query::erase::Erased<[u8; 8usize]>>
  17:        0x11072372c - <rustc_query_impl[465c999071b35b]::query_impl::mir_borrowck::dynamic_query::{closure#2} as core[6a5f4426c52daa32]::ops::function::FnOnce<(rustc_middle[a39402582bfd677]::ty::context::TyCtxt, rustc_span[2eda851f0959417e]::def_id::LocalDefId)>>::call_once
  18:        0x1106f6a9c - rustc_query_system[1b28c1e83e3a453c]::query::plumbing::try_execute_query::<rustc_query_impl[465c999071b35b]::DynamicConfig<rustc_query_system[1b28c1e83e3a453c]::query::caches::VecCache<rustc_span[2eda851f0959417e]::def_id::LocalDefId, rustc_middle[a39402582bfd677]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[465c999071b35b]::plumbing::QueryCtxt, true>
  19:        0x1108d4a44 - rustc_query_impl[465c999071b35b]::query_impl::mir_borrowck::get_query_incr::__rust_end_short_backtrace
  20:        0x10d5b48e8 - <core[6a5f4426c52daa32]::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures[f6cc48a9066b13bc]::sync::par_for_each_in<&[rustc_span[2eda851f0959417e]::def_id::LocalDefId], <rustc_middle[a39402582bfd677]::hir::map::Map>::par_body_owners<rustc_interface[df80c09a2aa6fb7f]::passes::analysis::{closure#1}::{closure#0}>::{closure#0}>::{closure#0}::{closure#0}> as core[6a5f4426c52daa32]::ops::function::FnOnce<()>>::call_once
  21:        0x10d5c1ed8 - rustc_data_structures[f6cc48a9066b13bc]::sync::par_for_each_in::<&[rustc_span[2eda851f0959417e]::def_id::LocalDefId], <rustc_middle[a39402582bfd677]::hir::map::Map>::par_body_owners<rustc_interface[df80c09a2aa6fb7f]::passes::analysis::{closure#1}::{closure#0}>::{closure#0}>
  22:        0x10d62bdc8 - rustc_interface[df80c09a2aa6fb7f]::passes::analysis
  23:        0x110841f30 - rustc_query_impl[465c999071b35b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[465c999071b35b]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a39402582bfd677]::query::erase::Erased<[u8; 1usize]>>
  24:        0x1107af73c - <rustc_query_impl[465c999071b35b]::query_impl::analysis::dynamic_query::{closure#2} as core[6a5f4426c52daa32]::ops::function::FnOnce<(rustc_middle[a39402582bfd677]::ty::context::TyCtxt, ())>>::call_once
  25:        0x1106a09c0 - rustc_query_system[1b28c1e83e3a453c]::query::plumbing::try_execute_query::<rustc_query_impl[465c999071b35b]::DynamicConfig<rustc_query_system[1b28c1e83e3a453c]::query::caches::SingleCache<rustc_middle[a39402582bfd677]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[465c999071b35b]::plumbing::QueryCtxt, true>
  26:        0x11072bfb0 - rustc_query_impl[465c999071b35b]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
  27:        0x10d527200 - <rustc_interface[df80c09a2aa6fb7f]::queries::QueryResult<&rustc_middle[a39402582bfd677]::ty::context::GlobalCtxt>>::enter::<core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>, rustc_driver_impl[21827c9a287a9f15]::run_compiler::{closure#1}::{closure#2}::{closure#4}>
  28:        0x10d569568 - <rustc_interface[df80c09a2aa6fb7f]::interface::Compiler>::enter::<rustc_driver_impl[21827c9a287a9f15]::run_compiler::{closure#1}::{closure#2}, core[6a5f4426c52daa32]::result::Result<core[6a5f4426c52daa32]::option::Option<rustc_interface[df80c09a2aa6fb7f]::queries::Linker>, rustc_span[2eda851f0959417e]::ErrorGuaranteed>>
  29:        0x10d5220b4 - rustc_span[2eda851f0959417e]::set_source_map::<core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>, rustc_interface[df80c09a2aa6fb7f]::interface::run_compiler<core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>, rustc_driver_impl[21827c9a287a9f15]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  30:        0x10d51882c - <scoped_tls[80ce123946cbe7a6]::ScopedKey<rustc_span[2eda851f0959417e]::SessionGlobals>>::set::<rustc_interface[df80c09a2aa6fb7f]::interface::run_compiler<core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>, rustc_driver_impl[21827c9a287a9f15]::run_compiler::{closure#1}>::{closure#0}, core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>>
  31:        0x10d525268 - std[12e62f360352ccd]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[df80c09a2aa6fb7f]::util::run_in_thread_pool_with_globals<rustc_interface[df80c09a2aa6fb7f]::interface::run_compiler<core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>, rustc_driver_impl[21827c9a287a9f15]::run_compiler::{closure#1}>::{closure#0}, core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>>
  32:        0x10d51641c - <<std[12e62f360352ccd]::thread::Builder>::spawn_unchecked_<rustc_interface[df80c09a2aa6fb7f]::util::run_in_thread_pool_with_globals<rustc_interface[df80c09a2aa6fb7f]::interface::run_compiler<core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>, rustc_driver_impl[21827c9a287a9f15]::run_compiler::{closure#1}>::{closure#0}, core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>>::{closure#1} as core[6a5f4426c52daa32]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  33:        0x1050be640 - std::sys::unix::thread::Thread::new::thread_start::h06dea01d0985d944
  34:        0x1a7b33fa8 - __pthread_joiner_wake

query stack during panic:
#0 [mir_borrowck] borrow-checking `accept_connection`
#1 [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: BoundUniversalRegionError { longer_fr: '?279, error_element: Location(bb0[0]), placeholder: Placeholder { universe: U14, bound: BoundRegion { var: 0, kind: BrNamed(DefId(36:1566 ~ tungstenite[c104]::handshake::server::{impl#2}::'_), '_) } } }
  |
  = note: delayed at compiler/rustc_borrowck/src/region_infer/mod.rs:1743:27
             0: std::backtrace::Backtrace::create
             1: <rustc_errors::HandlerInner>::emit_diagnostic
             2: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, alloc::string::String>
             3: <rustc_borrowck::diagnostics::region_errors::RegionErrors>::push::<rustc_borrowck::diagnostics::region_errors::RegionErrorKind>
             4: <rustc_borrowck::region_infer::RegionInferenceContext>::check_bound_universal_region
             5: <rustc_borrowck::region_infer::RegionInferenceContext>::solve
             6: rustc_borrowck::nll::compute_regions
             7: rustc_borrowck::do_mir_borrowck
             8: rustc_borrowck::mir_borrowck
             9: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
            10: <rustc_query_impl::query_impl::mir_borrowck::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId)>>::call_once
            11: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
            12: rustc_query_impl::query_impl::mir_borrowck::get_query_incr::__rust_end_short_backtrace
            13: <core::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures::sync::par_for_each_in<&[rustc_span::def_id::LocalDefId], <rustc_middle::hir::map::Map>::par_body_owners<rustc_interface::passes::analysis::{closure#1}::{closure#0}>::{closure#0}>::{closure#0}::{closure#0}> as core::ops::function::FnOnce<()>>::call_once
            14: rustc_data_structures::sync::par_for_each_in::<&[rustc_span::def_id::LocalDefId], <rustc_middle::hir::map::Map>::par_body_owners<rustc_interface::passes::analysis::{closure#1}::{closure#0}>::{closure#0}>
            15: rustc_interface::passes::analysis
            16: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
            17: <rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, ())>>::call_once
            18: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
            19: rustc_query_impl::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
            20: <rustc_interface::queries::QueryResult<&rustc_middle::ty::context::GlobalCtxt>>::enter::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}::{closure#2}::{closure#4}>
            21: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
            22: rustc_span::set_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
            23: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
            24: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
            25: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
            26: std::sys::unix::thread::Thread::new::thread_start
            27: __pthread_joiner_wake

error: internal compiler error: `compute_regions` tainted `infcx` with errors but did not emit any errors
   --> midgard/src/lib.rs:325:1
    |
325 | / fn accept_connection(stream: TcpStream, config: rustls::server::ServerConfig) -> Result<Socket> {
326 | |     let mut conn = rustls::server::ServerConnection::new(std::sync::Arc::new(config.clone()))?;
327 | |     let tlsstream = rustls::StreamOwned::new(conn, stream.try_clone()?);
328 | |     let f = |req, res| -> std::result::Result<tungstenite::handshake::server::Response, tungstenite::handshake::server::ErrorResponse> {
...   |
354 | |     }
355 | | }
    | |_^
    |
    = note: delayed at compiler/rustc_borrowck/src/nll.rs:310:52
               0: std::backtrace::Backtrace::create
               1: <rustc_errors::HandlerInner>::emit_diagnostic
               2: <rustc_session::session::Session>::delay_span_bug::<rustc_span::span_encoding::Span, &str>
               3: rustc_borrowck::nll::compute_regions
               4: rustc_borrowck::do_mir_borrowck
               5: rustc_borrowck::mir_borrowck
               6: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
               7: <rustc_query_impl::query_impl::mir_borrowck::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId)>>::call_once
               8: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
               9: rustc_query_impl::query_impl::mir_borrowck::get_query_incr::__rust_end_short_backtrace
              10: <core::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures::sync::par_for_each_in<&[rustc_span::def_id::LocalDefId], <rustc_middle::hir::map::Map>::par_body_owners<rustc_interface::passes::analysis::{closure#1}::{closure#0}>::{closure#0}>::{closure#0}::{closure#0}> as core::ops::function::FnOnce<()>>::call_once
              11: rustc_data_structures::sync::par_for_each_in::<&[rustc_span::def_id::LocalDefId], <rustc_middle::hir::map::Map>::par_body_owners<rustc_interface::passes::analysis::{closure#1}::{closure#0}>::{closure#0}>
              12: rustc_interface::passes::analysis
              13: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
              14: <rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, ())>>::call_once
              15: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
              16: rustc_query_impl::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
              17: <rustc_interface::queries::QueryResult<&rustc_middle::ty::context::GlobalCtxt>>::enter::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}::{closure#2}::{closure#4}>
              18: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
              19: rustc_span::set_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
              20: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
              21: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
              22: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
              23: std::sys::unix::thread::Thread::new::thread_start
              24: __pthread_joiner_wake
            

thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: failed while formatting fluent string `infer_trait_placeholder_mismatch`: 
the fluent string has an argument `trait_def_id` that was not found.
help: no arguments are available
', compiler/rustc_errors/src/emitter.rs:2397:77
stack backtrace:
   0:        0x101732cc0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hb75be2413dd8ceb3
   1:        0x101781a64 - core::fmt::write::h95d50546e769656f
   2:        0x101728e2c - std::io::Write::write_fmt::hce019ca594763835
   3:        0x101732b14 - std::sys_common::backtrace::print::hae7307dcada41b2a
   4:        0x101735578 - std::panicking::default_hook::{{closure}}::h30c41986d637ef23
   5:        0x101735380 - std::panicking::default_hook::h81d03189ef2e7e78
   6:        0x109be7f98 - rustc_driver_impl[21827c9a287a9f15]::install_ice_hook::{closure#0}
   7:        0x101735c2c - std::panicking::rust_panic_with_hook::he8360f4d28da55fc
   8:        0x101735a0c - std::panicking::begin_panic_handler::{{closure}}::he9e07d605072520f
   9:        0x1017330a0 - std::sys_common::backtrace::__rust_end_short_backtrace::he03bf52f9c1eb73a
  10:        0x101735780 - _rust_begin_unwind
  11:        0x1017ac9e0 - core::panicking::panic_fmt::ha5f5ca2311fff2ad
  12:        0x1017acda0 - core::result::unwrap_failed::h34067e5e60f3683e
  13:        0x10db8574c - <rustc_errors[8219b94d386394ca]::emitter::FileWithAnnotatedLines>::collect_annotations
  14:        0x10db8809c - <rustc_errors[8219b94d386394ca]::emitter::EmitterWriter>::emit_message_default::{closure#0}
  15:        0x10db8b494 - <rustc_errors[8219b94d386394ca]::emitter::EmitterWriter>::emit_messages_default
  16:        0x10db81c68 - <rustc_errors[8219b94d386394ca]::emitter::EmitterWriter as rustc_errors[8219b94d386394ca]::emitter::Emitter>::emit_diagnostic
  17:        0x10dbaba30 - <rustc_errors[8219b94d386394ca]::json::Diagnostic>::from_errors_diagnostic
  18:        0x10dbaa638 - <rustc_errors[8219b94d386394ca]::json::JsonEmitter as rustc_errors[8219b94d386394ca]::emitter::Emitter>::emit_diagnostic
  19:        0x10db962f0 - <rustc_errors[8219b94d386394ca]::HandlerInner>::emit_diagnostic::{closure#2}
  20:        0x10db95c48 - <rustc_errors[8219b94d386394ca]::HandlerInner>::emit_diagnostic
  21:        0x10db96998 - <rustc_errors[8219b94d386394ca]::HandlerInner>::flush_delayed::<alloc[e0f95eb21a34f6a8]::vec::Vec<rustc_errors[8219b94d386394ca]::DelayedDiagnostic>, &str>
  22:        0x10db931a0 - <rustc_errors[8219b94d386394ca]::HandlerInner as core[6a5f4426c52daa32]::ops::drop::Drop>::drop
  23:        0x109b8cc28 - core[6a5f4426c52daa32]::ptr::drop_in_place::<rustc_session[1039b6c2e3771dcd]::parse::ParseSess>
  24:        0x109b8e0d0 - core[6a5f4426c52daa32]::ptr::drop_in_place::<rustc_session[1039b6c2e3771dcd]::session::Session>
  25:        0x109ba4e88 - core[6a5f4426c52daa32]::ptr::drop_in_place::<rustc_interface[df80c09a2aa6fb7f]::interface::Compiler>
  26:        0x109ba24f0 - rustc_span[2eda851f0959417e]::set_source_map::<core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>, rustc_interface[df80c09a2aa6fb7f]::interface::run_compiler<core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>, rustc_driver_impl[21827c9a287a9f15]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  27:        0x109b9882c - <scoped_tls[80ce123946cbe7a6]::ScopedKey<rustc_span[2eda851f0959417e]::SessionGlobals>>::set::<rustc_interface[df80c09a2aa6fb7f]::interface::run_compiler<core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>, rustc_driver_impl[21827c9a287a9f15]::run_compiler::{closure#1}>::{closure#0}, core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>>
  28:        0x109ba5268 - std[12e62f360352ccd]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[df80c09a2aa6fb7f]::util::run_in_thread_pool_with_globals<rustc_interface[df80c09a2aa6fb7f]::interface::run_compiler<core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>, rustc_driver_impl[21827c9a287a9f15]::run_compiler::{closure#1}>::{closure#0}, core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>>
  29:        0x109b9641c - <<std[12e62f360352ccd]::thread::Builder>::spawn_unchecked_<rustc_interface[df80c09a2aa6fb7f]::util::run_in_thread_pool_with_globals<rustc_interface[df80c09a2aa6fb7f]::interface::run_compiler<core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>, rustc_driver_impl[21827c9a287a9f15]::run_compiler::{closure#1}>::{closure#0}, core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>>::{closure#1} as core[6a5f4426c52daa32]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  30:        0x10173e640 - std::sys::unix::thread::Thread::new::thread_start::h06dea01d0985d944
  31:        0x1a7b33fa8 - __pthread_joiner_wake

query stack during panic:
end of query stack
thread 'rustc' panicked at 'panic in a function that cannot unwind', library/core/src/panicking.rs:126:5
stack backtrace:
   0:        0x101732cc0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hb75be2413dd8ceb3
   1:        0x101781a64 - core::fmt::write::h95d50546e769656f
   2:        0x101728e2c - std::io::Write::write_fmt::hce019ca594763835
   3:        0x101732b14 - std::sys_common::backtrace::print::hae7307dcada41b2a
   4:        0x101735578 - std::panicking::default_hook::{{closure}}::h30c41986d637ef23
   5:        0x101735380 - std::panicking::default_hook::h81d03189ef2e7e78
   6:        0x109be7f98 - rustc_driver_impl[21827c9a287a9f15]::install_ice_hook::{closure#0}
   7:        0x101735c2c - std::panicking::rust_panic_with_hook::he8360f4d28da55fc
   8:        0x1017359d0 - std::panicking::begin_panic_handler::{{closure}}::he9e07d605072520f
   9:        0x1017330a0 - std::sys_common::backtrace::__rust_end_short_backtrace::he03bf52f9c1eb73a
  10:        0x101735780 - _rust_begin_unwind
  11:        0x1017aca10 - core::panicking::panic_nounwind_fmt::h6a635b966d82551e
  12:        0x1017aca8c - core::panicking::panic_nounwind::h241eff56ec55ba7a
  13:        0x1017acb80 - core::panicking::panic_cannot_unwind::h911ff5cd61f62d63
  14:        0x109ba2508 - rustc_span[2eda851f0959417e]::set_source_map::<core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>, rustc_interface[df80c09a2aa6fb7f]::interface::run_compiler<core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>, rustc_driver_impl[21827c9a287a9f15]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  15:        0x109b9882c - <scoped_tls[80ce123946cbe7a6]::ScopedKey<rustc_span[2eda851f0959417e]::SessionGlobals>>::set::<rustc_interface[df80c09a2aa6fb7f]::interface::run_compiler<core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>, rustc_driver_impl[21827c9a287a9f15]::run_compiler::{closure#1}>::{closure#0}, core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>>
  16:        0x109ba5268 - std[12e62f360352ccd]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[df80c09a2aa6fb7f]::util::run_in_thread_pool_with_globals<rustc_interface[df80c09a2aa6fb7f]::interface::run_compiler<core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>, rustc_driver_impl[21827c9a287a9f15]::run_compiler::{closure#1}>::{closure#0}, core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>>
  17:        0x109b9641c - <<std[12e62f360352ccd]::thread::Builder>::spawn_unchecked_<rustc_interface[df80c09a2aa6fb7f]::util::run_in_thread_pool_with_globals<rustc_interface[df80c09a2aa6fb7f]::interface::run_compiler<core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>, rustc_driver_impl[21827c9a287a9f15]::run_compiler::{closure#1}>::{closure#0}, core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[6a5f4426c52daa32]::result::Result<(), rustc_span[2eda851f0959417e]::ErrorGuaranteed>>::{closure#1} as core[6a5f4426c52daa32]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  18:        0x10173e640 - std::sys::unix::thread::Thread::new::thread_start::h06dea01d0985d944
  19:        0x1a7b33fa8 - __pthread_joiner_wake

note: rustc 1.71.1 (eb26296b5 2023-08-03) running on aarch64-apple-darwin

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

Activity

added
C-bugCategory: This is a bug.
I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Aug 16, 2023
added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Aug 16, 2023
changed the title [-]Bug report[/-] [+]ICE in rustc_borrowck/src/region_infer[/+] on Aug 17, 2023
lqd

lqd commented on Aug 17, 2023

@lqd
Member

@sjeohp The code snippet is incomplete: is there a repository available that we could try, to reproduce the error? If not, could you at least add the full accept_connection function?
Thanks!

sjeohp

sjeohp commented on Aug 17, 2023

@sjeohp
Author
use tungstenite::handshake::server::{Response, ErrorResponse};
fn accept_connection(stream: TcpStream, config: rustls::server::ServerConfig) -> Result<Socket> {
    let mut conn = rustls::server::ServerConnection::new(std::sync::Arc::new(config.clone()))?;
    let tlsstream = rustls::StreamOwned::new(conn, stream.try_clone()?);
    if let Ok(ws) = match tungstenite::accept_hdr_with_config(tlsstream, |req, res| -> std::result::Result<Response, ErrorResponse> {
        let callback = |req, res| -> std::result::Result<tungstenite::handshake::server::Response, tungstenite::handshake::server::ErrorResponse> {
            dbg!(&req);
            dbg!(&res);
            Ok(res)
        }; 
        if let Ok(ws) = match tungstenite::accept_hdr_with_config(tlsstream, callback, None) {
        Err(HandshakeError::Interrupted(midhandshake)) => {
            info!(
                "Handshake interrupted with peer {} - waiting to try again.",
                peer_addr
            );  
            Ok(Socket::Interrupted(midhandshake))
        }   

        Err(e) => {
            error!("Error accepting secure websocket connection: {e}");
            Err(e)?
        }   

        Ok(ws) => Ok(Socket::SecureWebSocket(ws)),
    }   
}
}
lqd

lqd commented on Aug 17, 2023

@lqd
Member

@sjeohp This is still incomplete and doesn't parse.

Do you have a repository where the issue can be reproduced?

self-assigned this
on Aug 17, 2023
sjeohp

sjeohp commented on Aug 17, 2023

@sjeohp
Author

No repo. You can make it parse pretty easily. I am not a rustc expert but I believe the issue was with the callback.

added
E-needs-bisectionCall for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc
E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example
on Aug 18, 2023
lqd

lqd commented on Aug 18, 2023

@lqd
Member

Here's a small (but not minimal yet) working repro:

use std::io::{self, Read, Write};

struct S;

impl Read for S {
    fn read(&mut self, _buf: &mut [u8]) -> io::Result<usize> {
        todo!()
    }
}

impl Write for S {
    fn write(&mut self, _buf: &[u8]) -> io::Result<usize> {
        todo!()
    }

    fn flush(&mut self) -> io::Result<()> {
        todo!()
    }
}

fn main() {
    let s = S;
    tungstenite::accept_hdr(s, |_, _| {
        let callback = |_, _| {
            todo!()
        };

        tungstenite::accept_hdr(s, callback);
        todo!()
    });
}

and with that we can finally bisect, to nightly-2022-06-08:

I'll minimize tungstenite next to remove this dependency and create an MCVE.

added and removed
E-needs-bisectionCall for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc
on Aug 18, 2023

16 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-borrow-checkerArea: The borrow checkerA-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @lqd@matthiaskrgr@apiraino@aliemjay@rustbot

    Issue actions

      ICE in rustc_borrowck/src/region_infer · Issue #114907 · rust-lang/rust