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

(nightly) internal compiler error: union fields that need dropping should be impossible #99375

Closed
papricasix opened this issue Jul 17, 2022 · 1 comment · Fixed by #99384
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

@papricasix
Copy link

While compiling rlua using a nightly build of rust, I triggered the following bug (in https://github.com/amethyst/rlua/blob/10c95b7ffa8ad1a64f755a05c7cf806211f3f27f/src/util.rs#L129):

Code

    unsafe extern "C" fn do_call<F, R>(state: *mut ffi::lua_State) -> c_int
    where
        R: Copy,
        F: Fn(*mut ffi::lua_State) -> R,
    {
        let params = ffi::lua_touserdata(state, -1) as *mut Params<F, R>;
        ffi::lua_pop(state, 1);

        (*params).result.init = ((*params).function)(state);

        if (*params).nresults == ffi::LUA_MULTRET {
            ffi::lua_gettop(state)
        } else {
            (*params).nresults
        }
    }

Meta

rustc --version --verbose:

rustc 1.64.0-nightly (d5e7f4782 2022-07-16)
binary: rustc
commit-hash: d5e7f4782e4b699728d0a08200ecd1a54d56a85d
commit-date: 2022-07-16
host: x86_64-unknown-linux-gnu
release: 1.64.0-nightly
LLVM version: 14.0.6

Error output

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: union fields that need dropping should be impossible
   --> /home/micha/.cargo/registry/src/github.com-1ecc6299db9ec823/rlua-0.19.2/src/util.rs:129:9
    |
129 |         (*params).result.init = ((*params).function)(state);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: delayed at compiler/rustc_mir_transform/src/check_unsafety.rs:227:39

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1425:13
Backtrace

stack backtrace:
   0:     0x7fca884a3710 - std::backtrace_rs::backtrace::libunwind::trace::he2b7f064c6c8ebd8
                               at /rustc/d5e7f4782e4b699728d0a08200ecd1a54d56a85d/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7fca884a3710 - std::backtrace_rs::backtrace::trace_unsynchronized::h6c5848816085cb4d
                               at /rustc/d5e7f4782e4b699728d0a08200ecd1a54d56a85d/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fca884a3710 - std::sys_common::backtrace::_print_fmt::h05ef0be136010689
                               at /rustc/d5e7f4782e4b699728d0a08200ecd1a54d56a85d/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7fca884a3710 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h10c19668734af2a3
                               at /rustc/d5e7f4782e4b699728d0a08200ecd1a54d56a85d/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7fca884fd81c - core::fmt::write::hb483b6baf6f08a60
                               at /rustc/d5e7f4782e4b699728d0a08200ecd1a54d56a85d/library/core/src/fmt/mod.rs:1198:17
   5:     0x7fca88494b75 - std::io::Write::write_fmt::hf77bd6f7d58fef0e
                               at /rustc/d5e7f4782e4b699728d0a08200ecd1a54d56a85d/library/std/src/io/mod.rs:1672:15
   6:     0x7fca884a63e1 - std::sys_common::backtrace::_print::h03f34c62e5bfdc80
                               at /rustc/d5e7f4782e4b699728d0a08200ecd1a54d56a85d/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7fca884a63e1 - std::sys_common::backtrace::print::he0f61808579de256
                               at /rustc/d5e7f4782e4b699728d0a08200ecd1a54d56a85d/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7fca884a63e1 - std::panicking::default_hook::{{closure}}::h03e5cc363b5f6eb0
                               at /rustc/d5e7f4782e4b699728d0a08200ecd1a54d56a85d/library/std/src/panicking.rs:295:22
   9:     0x7fca884a60b3 - std::panicking::default_hook::h2bb8a9d1f237276a
                               at /rustc/d5e7f4782e4b699728d0a08200ecd1a54d56a85d/library/std/src/panicking.rs:314:9
  10:     0x7fca88d4f7f1 - rustc_driver[8f049ba7ec2fe4e]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7fca884a6bb6 - std::panicking::rust_panic_with_hook::h2b6418ec29aa433e
                               at /rustc/d5e7f4782e4b699728d0a08200ecd1a54d56a85d/library/std/src/panicking.rs:702:17
  12:     0x7fca89f27531 - std[c33fd1b84eff1e1b]::panicking::begin_panic::<rustc_errors[2e7ae59e55ccb0de]::ExplicitBug>::{closure#0}
  13:     0x7fca89f272c6 - std[c33fd1b84eff1e1b]::sys_common::backtrace::__rust_end_short_backtrace::<std[c33fd1b84eff1e1b]::panicking::begin_panic<rustc_errors[2e7ae59e55ccb0de]::ExplicitBug>::{closure#0}, !>
  14:     0x7fca89f210c6 - std[c33fd1b84eff1e1b]::panicking::begin_panic::<rustc_errors[2e7ae59e55ccb0de]::ExplicitBug>
  15:     0x7fca89f243b6 - std[c33fd1b84eff1e1b]::panic::panic_any::<rustc_errors[2e7ae59e55ccb0de]::ExplicitBug>
  16:     0x7fca8b81c0e3 - <rustc_errors[2e7ae59e55ccb0de]::HandlerInner as core[8559c76fbb49d2ec]::ops::drop::Drop>::drop
  17:     0x7fca8af46cab - core[8559c76fbb49d2ec]::ptr::drop_in_place::<rustc_session[f28dbaef20431e1d]::parse::ParseSess>
  18:     0x7fca8af491e3 - <alloc[34fcb9634b68b8d8]::rc::Rc<rustc_session[f28dbaef20431e1d]::session::Session> as core[8559c76fbb49d2ec]::ops::drop::Drop>::drop
  19:     0x7fca8af2b64d - core[8559c76fbb49d2ec]::ptr::drop_in_place::<rustc_interface[d0628200c9d01d52]::interface::Compiler>
  20:     0x7fca8af29804 - rustc_span[1b79d0b79e871695]::with_source_map::<core[8559c76fbb49d2ec]::result::Result<(), rustc_errors[2e7ae59e55ccb0de]::ErrorGuaranteed>, rustc_interface[d0628200c9d01d52]::interface::create_compiler_and_run<core[8559c76fbb49d2ec]::result::Result<(), rustc_errors[2e7ae59e55ccb0de]::ErrorGuaranteed>, rustc_driver[8f049ba7ec2fe4e]::run_compiler::{closure#1}>::{closure#1}>
  21:     0x7fca8af45aa0 - rustc_interface[d0628200c9d01d52]::interface::create_compiler_and_run::<core[8559c76fbb49d2ec]::result::Result<(), rustc_errors[2e7ae59e55ccb0de]::ErrorGuaranteed>, rustc_driver[8f049ba7ec2fe4e]::run_compiler::{closure#1}>
  22:     0x7fca8af59be2 - <scoped_tls[1595f96802d8f51d]::ScopedKey<rustc_span[1b79d0b79e871695]::SessionGlobals>>::set::<rustc_interface[d0628200c9d01d52]::interface::run_compiler<core[8559c76fbb49d2ec]::result::Result<(), rustc_errors[2e7ae59e55ccb0de]::ErrorGuaranteed>, rustc_driver[8f049ba7ec2fe4e]::run_compiler::{closure#1}>::{closure#0}, core[8559c76fbb49d2ec]::result::Result<(), rustc_errors[2e7ae59e55ccb0de]::ErrorGuaranteed>>
  23:     0x7fca8af2bbcf - std[c33fd1b84eff1e1b]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[d0628200c9d01d52]::util::run_in_thread_pool_with_globals<rustc_interface[d0628200c9d01d52]::interface::run_compiler<core[8559c76fbb49d2ec]::result::Result<(), rustc_errors[2e7ae59e55ccb0de]::ErrorGuaranteed>, rustc_driver[8f049ba7ec2fe4e]::run_compiler::{closure#1}>::{closure#0}, core[8559c76fbb49d2ec]::result::Result<(), rustc_errors[2e7ae59e55ccb0de]::ErrorGuaranteed>>::{closure#0}, core[8559c76fbb49d2ec]::result::Result<(), rustc_errors[2e7ae59e55ccb0de]::ErrorGuaranteed>>
  24:     0x7fca8af45ef9 - <<std[c33fd1b84eff1e1b]::thread::Builder>::spawn_unchecked_<rustc_interface[d0628200c9d01d52]::util::run_in_thread_pool_with_globals<rustc_interface[d0628200c9d01d52]::interface::run_compiler<core[8559c76fbb49d2ec]::result::Result<(), rustc_errors[2e7ae59e55ccb0de]::ErrorGuaranteed>, rustc_driver[8f049ba7ec2fe4e]::run_compiler::{closure#1}>::{closure#0}, core[8559c76fbb49d2ec]::result::Result<(), rustc_errors[2e7ae59e55ccb0de]::ErrorGuaranteed>>::{closure#0}, core[8559c76fbb49d2ec]::result::Result<(), rustc_errors[2e7ae59e55ccb0de]::ErrorGuaranteed>>::{closure#1} as core[8559c76fbb49d2ec]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  25:     0x7fca884b0923 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h6d78f1dcc4e189b8
                               at /rustc/d5e7f4782e4b699728d0a08200ecd1a54d56a85d/library/alloc/src/boxed.rs:1935:9
  26:     0x7fca884b0923 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc462dd82c109fc34
                               at /rustc/d5e7f4782e4b699728d0a08200ecd1a54d56a85d/library/alloc/src/boxed.rs:1935:9
  27:     0x7fca884b0923 - std::sys::unix::thread::Thread::new::thread_start::h671a7ad89d56ef6e
                               at /rustc/d5e7f4782e4b699728d0a08200ecd1a54d56a85d/library/std/src/sys/unix/thread.rs:108:17
  28:     0x7fca8808c54d - <unknown>
  29:     0x7fca88111874 - clone
  30:                0x0 - <unknown>

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.64.0-nightly (d5e7f4782 2022-07-16) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C opt-level=3 -C embed-bitcode=no -C linker=clang -C link-arg=-fuse-ld=lld -Z share-generics=y -C link-arg=-Wl,--no-rosegment

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

query stack during panic:
end of query stack
error: could not compile `rlua`

@papricasix papricasix 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 Jul 17, 2022
@papricasix papricasix changed the title internal compiler error: union fields that need dropping should be impossible (nightly) internal compiler error: union fields that need dropping should be impossible Jul 17, 2022
@carbotaniuman
Copy link
Contributor

This looks related to #97995.

@compiler-errors compiler-errors self-assigned this Jul 17, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jul 18, 2022
use body's param-env when checking if type needs drop

The type comes from the body, so we should be using the body's param-env, as opposed to the ADT's param env, because we know less in the latter compared to the former.

Fixes rust-lang#99375
@bors bors closed this as completed in 3147392 Jul 19, 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) ❄️ 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.

3 participants