Skip to content

Crash using mlua crate. #99568

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

Closed
Emm54321 opened this issue Jul 21, 2022 · 4 comments
Closed

Crash using mlua crate. #99568

Emm54321 opened this issue Jul 21, 2022 · 4 comments
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

@Emm54321
Copy link

Code

pub fn lua_touserdata() -> *mut () {
    unimplemented!()
}

pub union URes<R: Copy> {
    _uninit: (),
    init: R,
}

pub struct Params<F, R: Copy> {
    function: F,
    result: URes<R>,
}

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

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

Meta

rustc --version --verbose:

rustc 1.64.0-nightly (f8588549c 2022-07-18)
binary: rustc
commit-hash: f8588549c3c3d45c32b404210cada01e2a45def3
commit-date: 2022-07-18
host: x86_64-unknown-linux-gnu
release: 1.64.0-nightly
LLVM version: 14.0.6

Error output

    Checking yy v0.1.0 (/tmp/yy)
warning: Error finalizing incremental compilation session directory `/tmp/yy/target/debug/incremental/yy-uwxkiexch4q/s-gbv0o20hj6-12w3nk9-working`: No such file or directory (os error 2)

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
  --> src/lib.rs:22:5
   |
22 |     (*params).result.init = ((*params).function)();
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = 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

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 (f8588549c 2022-07-18) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C incremental -C target-feature=+aes

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

query stack during panic:
end of query stack
warning: `yy` (lib) generated 1 warning
error: could not compile `yy`; 1 warning emitted
Backtrace

stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: std::panic::panic_any::<rustc_errors::ExplicitBug>
   2: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
   3: core::ptr::drop_in_place::<rustc_session::parse::ParseSess>
   4: <alloc::rc::Rc<rustc_session::session::Session> as core::ops::drop::Drop>::drop
   5: core::ptr::drop_in_place::<rustc_interface::interface::Compiler>
   6: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
   7: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>
   8: <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.

@Emm54321 Emm54321 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 21, 2022
@5225225
Copy link
Contributor

5225225 commented Jul 21, 2022

Looks like this was fixed by #99384 ? A bisection lead to the same regressed PR, and I can't reproduce this on the latest nightly (rustc 1.64.0-nightly (d68e7ebc3 2022-07-20)).

@Emm54321
Copy link
Author

Indeed, it works with 2022-07-20.
I assumed 'rustup update' would give me the latest nightly version, but it gave me 2022-07-18.

@5225225
Copy link
Contributor

5225225 commented Jul 21, 2022

I assumed 'rustup update' would give me the latest nightly version, but it gave me 2022-07-18.

rustup update will skip versions that don't have all the components you have, to avoid things not working. Do you have miri installed? Miri doesn't work in the latest versions.

@Emm54321
Copy link
Author

Ah right, I have miri installed.
Anyway, thanks for your time.

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

No branches or pull requests

2 participants