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

ice: called Result::unwrap() on an Err value: Unknown(<SeStr<S, E> as std::ptr::Pointee>::Metadata) #115628

Closed
matthiaskrgr opened this issue Sep 7, 2023 · 8 comments · Fixed by #115631
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

Code

trait Structure<E>: Sized {
    type RefTarget: ?Sized;
}

struct SeStr<S, E>
where
    S: Structure<E>,
{
    _data: S::RefTarget,
}

impl<S, E> SeStr<S, E>
where
    S: Structure<E>,
{
    pub extern "C" fn from_ptr<'a>() -> Option<&'a Self> {
        panic!()
    }
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.74.0-nightly (a991861ec 2023-09-05)
binary: rustc
commit-hash: a991861ec9fd8aedffbe5744a8852c7c64dd40b2
commit-date: 2023-09-05
host: x86_64-unknown-linux-gnu
release: 1.74.0-nightly
LLVM version: 17.0.0

Error output

warning: struct `SeStr` is never constructed
 --> 81AFF1B75E2344DCA73671B83CCF8326D9F0BD10E402451EC2DCC412A42E097A.rs:5:8
  |
5 | struct SeStr<S, E>
  |        ^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: associated function `from_ptr` is never used
  --> 81AFF1B75E2344DCA73671B83CCF8326D9F0BD10E402451EC2DCC412A42E097A.rs:16:23
   |
12 | impl<S, E> SeStr<S, E>
   | ---------------------- associated function in this implementation
...
16 |     pub extern "C" fn from_ptr<'a>() -> Option<&'a Self> {
   |                       ^^^^^^^^
Backtrace

called `Result::unwrap()` on an `Err` value: Unknown(<SeStr<S, E> as std::ptr::Pointee>::Metadata)
stack backtrace:
   0:     0x7fc73b4dcbec - std::backtrace_rs::backtrace::libunwind::trace::h1298100820b00e42
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7fc73b4dcbec - std::backtrace_rs::backtrace::trace_unsynchronized::h25ae9be29b50d68d
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fc73b4dcbec - std::sys_common::backtrace::_print_fmt::hb0a122c02a9e329f
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7fc73b4dcbec - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h0785508acad78739
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fc73b542dfc - core::fmt::rt::Argument::fmt::h367a8235fd3b8ec9
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/core/src/fmt/rt.rs:138:9
   5:     0x7fc73b542dfc - core::fmt::write::haf0f122656cf716d
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/core/src/fmt/mod.rs:1094:21
   6:     0x7fc73b4cf71e - std::io::Write::write_fmt::h81969da61711600d
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/std/src/io/mod.rs:1714:15
   7:     0x7fc73b4dc9d4 - std::sys_common::backtrace::_print::h00e5c4a2e9966b17
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fc73b4dc9d4 - std::sys_common::backtrace::print::hbf7a0e8e19400072
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fc73b4dfaca - std::panicking::panic_hook_with_disk_dump::{{closure}}::h27904b15b8804b04
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/std/src/panicking.rs:280:22
  10:     0x7fc73b4df7c5 - std::panicking::panic_hook_with_disk_dump::h0a17a9fc902df4ec
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/std/src/panicking.rs:314:9
  11:     0x7fc73a31c6d9 - rustc_driver_impl[421f961c2abd6a6c]::install_ice_hook::{closure#0}
  12:     0x7fc73b4e0383 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::he211df56096a7722
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/alloc/src/boxed.rs:2021:9
  13:     0x7fc73b4e0383 - std::panicking::rust_panic_with_hook::h2ec7fb05ba41ff26
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/std/src/panicking.rs:757:13
  14:     0x7fc73b4e0101 - std::panicking::begin_panic_handler::{{closure}}::h2b92262374748ae8
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/std/src/panicking.rs:631:13
  15:     0x7fc73b4dd116 - std::sys_common::backtrace::__rust_end_short_backtrace::h0b659f8569fc6095
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/std/src/sys_common/backtrace.rs:170:18
  16:     0x7fc73b4dfe42 - rust_begin_unwind
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/std/src/panicking.rs:619:5
  17:     0x7fc73b53f1a5 - core::panicking::panic_fmt::heae4b517db4316e6
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/core/src/panicking.rs:72:14
  18:     0x7fc73b53f833 - core::result::unwrap_failed::h769a8cbef1f880e8
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/core/src/result.rs:1652:5
  19:     0x7fc7394c7722 - rustc_lint[1fe2be5320867f18]::types::repr_nullable_ptr
  20:     0x7fc7394c64ac - <rustc_lint[1fe2be5320867f18]::types::ImproperCTypesVisitor>::check_type_for_ffi
  21:     0x7fc73904e7fa - <rustc_lint[1fe2be5320867f18]::types::ImproperCTypesVisitor>::check_type_for_ffi_and_report_errors
  22:     0x7fc73904e652 - <rustc_lint[1fe2be5320867f18]::types::ImproperCTypesVisitor>::check_foreign_fn
  23:     0x7fc73904af84 - rustc_hir[b0c722804e360960]::intravisit::walk_impl_item::<rustc_lint[1fe2be5320867f18]::late::LateContextAndPass<rustc_lint[1fe2be5320867f18]::BuiltinCombinedModuleLateLintPass>>
  24:     0x7fc7390488fc - rustc_hir[b0c722804e360960]::intravisit::walk_item::<rustc_lint[1fe2be5320867f18]::late::LateContextAndPass<rustc_lint[1fe2be5320867f18]::BuiltinCombinedModuleLateLintPass>>
  25:     0x7fc7390484c5 - <rustc_lint[1fe2be5320867f18]::late::LateContextAndPass<rustc_lint[1fe2be5320867f18]::BuiltinCombinedModuleLateLintPass> as rustc_hir[b0c722804e360960]::intravisit::Visitor>::visit_nested_item
  26:     0x7fc739047c9a - rustc_lint[1fe2be5320867f18]::late::late_lint_mod::<rustc_lint[1fe2be5320867f18]::BuiltinCombinedModuleLateLintPass>
  27:     0x7fc739047a4a - rustc_lint[1fe2be5320867f18]::lint_mod
  28:     0x7fc73903b88c - rustc_query_impl[e4e476eeb45651d1]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e4e476eeb45651d1]::query_impl::lint_mod::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7266ccbfd6f08af0]::query::erase::Erased<[u8; 0usize]>>
  29:     0x7fc73903b86e - <rustc_query_impl[e4e476eeb45651d1]::query_impl::lint_mod::dynamic_query::{closure#2} as core[91a7ba3c96b8fb6a]::ops::function::FnOnce<(rustc_middle[7266ccbfd6f08af0]::ty::context::TyCtxt, rustc_span[e182e80647a6f439]::def_id::LocalModDefId)>>::call_once
  30:     0x7fc7392f22a8 - rustc_query_system[44d60dfb7090b806]::query::plumbing::try_execute_query::<rustc_query_impl[e4e476eeb45651d1]::DynamicConfig<rustc_query_system[44d60dfb7090b806]::query::caches::DefaultCache<rustc_span[e182e80647a6f439]::def_id::LocalModDefId, rustc_middle[7266ccbfd6f08af0]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[e4e476eeb45651d1]::plumbing::QueryCtxt, false>
  31:     0x7fc739cb75e4 - rustc_query_impl[e4e476eeb45651d1]::query_impl::lint_mod::get_query_non_incr::__rust_end_short_backtrace
  32:     0x7fc7399db62e - rustc_data_structures[4483c8f9b2693f2d]::sync::par_for_each_in::<&[rustc_hir[b0c722804e360960]::hir_id::OwnerId], <rustc_middle[7266ccbfd6f08af0]::hir::map::Map>::par_for_each_module<rustc_lint[1fe2be5320867f18]::late::check_crate::{closure#1}::{closure#0}::{closure#0}>::{closure#0}>
  33:     0x7fc7399db3bb - <rustc_session[a813519ed55dc798]::session::Session>::time::<(), rustc_lint[1fe2be5320867f18]::late::check_crate::{closure#1}::{closure#0}>
  34:     0x7fc739782fc1 - rustc_data_structures[4483c8f9b2693f2d]::sync::join::<rustc_lint[1fe2be5320867f18]::late::check_crate::{closure#0}, rustc_lint[1fe2be5320867f18]::late::check_crate::{closure#1}, (), ()>
  35:     0x7fc739782d59 - <core[91a7ba3c96b8fb6a]::panic::unwind_safe::AssertUnwindSafe<rustc_interface[e402a4e95d47e40d]::passes::analysis::{closure#6}::{closure#1}::{closure#0}::{closure#0}::{closure#2}> as core[91a7ba3c96b8fb6a]::ops::function::FnOnce<()>>::call_once
  36:     0x7fc739782c79 - <rustc_data_structures[4483c8f9b2693f2d]::sync::ParallelGuard>::run::<(), rustc_interface[e402a4e95d47e40d]::passes::analysis::{closure#6}::{closure#1}::{closure#0}::{closure#0}::{closure#2}>
  37:     0x7fc739782a40 - <rustc_data_structures[4483c8f9b2693f2d]::sync::ParallelGuard>::run::<(), rustc_interface[e402a4e95d47e40d]::passes::analysis::{closure#6}::{closure#1}::{closure#0}>
  38:     0x7fc739782402 - <rustc_session[a813519ed55dc798]::session::Session>::time::<(), rustc_interface[e402a4e95d47e40d]::passes::analysis::{closure#6}>
  39:     0x7fc7397805bc - rustc_interface[e402a4e95d47e40d]::passes::analysis
  40:     0x7fc7397a45ea - rustc_query_impl[e4e476eeb45651d1]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e4e476eeb45651d1]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7266ccbfd6f08af0]::query::erase::Erased<[u8; 1usize]>>
  41:     0x7fc7397a45d9 - <rustc_query_impl[e4e476eeb45651d1]::query_impl::analysis::dynamic_query::{closure#2} as core[91a7ba3c96b8fb6a]::ops::function::FnOnce<(rustc_middle[7266ccbfd6f08af0]::ty::context::TyCtxt, ())>>::call_once
  42:     0x7fc739a62c64 - rustc_query_system[44d60dfb7090b806]::query::plumbing::try_execute_query::<rustc_query_impl[e4e476eeb45651d1]::DynamicConfig<rustc_query_system[44d60dfb7090b806]::query::caches::SingleCache<rustc_middle[7266ccbfd6f08af0]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[e4e476eeb45651d1]::plumbing::QueryCtxt, false>
  43:     0x7fc739a629d9 - rustc_query_impl[e4e476eeb45651d1]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  44:     0x7fc739834f33 - <rustc_middle[7266ccbfd6f08af0]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[421f961c2abd6a6c]::run_compiler::{closure#1}::{closure#2}::{closure#6}, core[91a7ba3c96b8fb6a]::result::Result<(), rustc_span[e182e80647a6f439]::ErrorGuaranteed>>
  45:     0x7fc73983403c - <rustc_interface[e402a4e95d47e40d]::interface::Compiler>::enter::<rustc_driver_impl[421f961c2abd6a6c]::run_compiler::{closure#1}::{closure#2}, core[91a7ba3c96b8fb6a]::result::Result<core[91a7ba3c96b8fb6a]::option::Option<rustc_interface[e402a4e95d47e40d]::queries::Linker>, rustc_span[e182e80647a6f439]::ErrorGuaranteed>>
  46:     0x7fc73982ba38 - std[2ba0c775535575e]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[e402a4e95d47e40d]::util::run_in_thread_with_globals<rustc_interface[e402a4e95d47e40d]::interface::run_compiler<core[91a7ba3c96b8fb6a]::result::Result<(), rustc_span[e182e80647a6f439]::ErrorGuaranteed>, rustc_driver_impl[421f961c2abd6a6c]::run_compiler::{closure#1}>::{closure#0}, core[91a7ba3c96b8fb6a]::result::Result<(), rustc_span[e182e80647a6f439]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[91a7ba3c96b8fb6a]::result::Result<(), rustc_span[e182e80647a6f439]::ErrorGuaranteed>>
  47:     0x7fc73982b1ae - <<std[2ba0c775535575e]::thread::Builder>::spawn_unchecked_<rustc_interface[e402a4e95d47e40d]::util::run_in_thread_with_globals<rustc_interface[e402a4e95d47e40d]::interface::run_compiler<core[91a7ba3c96b8fb6a]::result::Result<(), rustc_span[e182e80647a6f439]::ErrorGuaranteed>, rustc_driver_impl[421f961c2abd6a6c]::run_compiler::{closure#1}>::{closure#0}, core[91a7ba3c96b8fb6a]::result::Result<(), rustc_span[e182e80647a6f439]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[91a7ba3c96b8fb6a]::result::Result<(), rustc_span[e182e80647a6f439]::ErrorGuaranteed>>::{closure#1} as core[91a7ba3c96b8fb6a]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  48:     0x7fc73b4ead35 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc5c2793cdb16fd0c
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/alloc/src/boxed.rs:2007:9
  49:     0x7fc73b4ead35 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hd102196bf71bb167
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/alloc/src/boxed.rs:2007:9
  50:     0x7fc73b4ead35 - std::sys::unix::thread::Thread::new::thread_start::hd2018bce9981ca61
                               at /rustc/a991861ec9fd8aedffbe5744a8852c7c64dd40b2/library/std/src/sys/unix/thread.rs:108:17
  51:     0x7fc736e8c9eb - <unknown>
  52:     0x7fc736f10dfc - <unknown>
  53:                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: please attach the file at `/tmp/im/3/icemaker_reduced/rustc-ice-2023-09-07T04:45:00.434074666Z-1745259.txt` to your bug report

query stack during panic:
#0 [lint_mod] linting top-level module
#1 [analysis] running analysis passes on this crate
end of query stack

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. labels Sep 7, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 7, 2023
@matthiaskrgr matthiaskrgr added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Sep 7, 2023
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Sep 7, 2023
@matthiaskrgr
Copy link
Member Author

build-pass -> ice in nightly-2020-07-31

commit[0] 2020-07-29: Auto merge of #74733 - richkadel:llvm-coverage-map-gen-5, r=tmandry
commit[1] 2020-07-29: Auto merge of #73767 - P1n3appl3:rustdoc-formats, r=tmandry
commit[2] 2020-07-30: Auto merge of #74929 - Manishearth:rollup-z2vflrp, r=Manishearth
commit[3] 2020-07-30: Auto merge of #74923 - ehuss:update-cargo, r=Mark-Simulacrum
commit[4] 2020-07-30: Auto merge of #74876 - oli-obk:lumberjack_disable, r=RalfJung
commit[5] 2020-07-30: Auto merge of #74105 - npmccallum:naked, r=matthewjasper
commit[6] 2020-07-30: Auto merge of #74930 - ecstatic-morse:const-size-align-of-val, r=oli-obk
commit[7] 2020-07-30: Auto merge of #73990 - jumbatm:clashing-extern-decl, r=nagisa
commit[8] 2020-07-30: Auto merge of #74908 - RalfJung:miri, r=RalfJung
commit[9] 2020-07-30: Auto merge of #74957 - Manishearth:rollup-3wudwlg, r=Manishearth
ERROR: no CI builds available between db0492a and cfc572c

@matthiaskrgr
Copy link
Member Author

probably #73990 ?

@matthiaskrgr matthiaskrgr added the P-critical Critical priority label Sep 7, 2023
@compiler-errors
Copy link
Member

@matthiaskrgr why did you mark this as P-critical if it's a stable-to-stable regression from 2020?

@compiler-errors
Copy link
Member

compiler-errors commented Sep 7, 2023

Minimal:

extern "C" fn foo<T: ?Sized + 'static>() -> Option<&'static T> { None }

@Noratrieb Noratrieb removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 7, 2023
@compiler-errors compiler-errors removed the P-critical Critical priority label Sep 7, 2023
@matthiaskrgr
Copy link
Member Author

its a regression build pass -> ice which is critical according to the rustc dev guide

@compiler-errors
Copy link
Member

compiler-errors commented Sep 7, 2023

According to https://forge.rust-lang.org/compiler/prioritization/priority-levels.html (not the dev guide, which I was confused since the dev guide doesn't really mention criteria for priority):

If a regression has been in stable for a release or two (either because we are still awaiting a fix, or because the bug had laid dormant i.e. undetected), we typically lower the priority as well, because by that time, if the users have not raised a ruckus about the regression, that is a sign that it is inherently not a critical issue.

This is a regression since like 1.47, so I don't think it necessarily needs to block a release to fix 😺

@matthiaskrgr
Copy link
Member Author

Ah sorry that's what i meant, right guess its p high then. 👍

@apiraino
Copy link
Contributor

apiraino commented Sep 7, 2023

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-medium

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Sep 7, 2023
@bors bors closed this as completed in 5a2b589 Sep 11, 2023
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Sep 11, 2023
Rollup merge of rust-lang#115631 - compiler-errors:ctypes-unsized, r=davidtwco

Don't ICE when computing ctype's `repr_nullable_ptr` for possibly-unsized ty

We may not always be able to compute the layout of a type like `&T` when `T: ?Sized`, even if we're able to estimate its size skeleton.

r? davidtwco

Fixes rust-lang#115628
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) ❄️ P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. 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.

5 participants