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

Broken LLVM with GAT #74684

Closed
Tracked by #44265
DutchGhost opened this issue Jul 23, 2020 · 3 comments · Fixed by #79554
Closed
Tracked by #44265

Broken LLVM with GAT #74684

DutchGhost opened this issue Jul 23, 2020 · 3 comments · Fixed by #79554
Labels
A-codegen Area: Code generation C-bug Category: This is a bug. F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@DutchGhost
Copy link
Contributor

DutchGhost commented Jul 23, 2020

I tried this code:

#![feature(generic_associated_types)]
trait Fun {
    type F<'a>: ?Sized;
    
    fn identity<'a>(t: &'a Self::F<'a>) -> &'a Self::F<'a> { t }
}

impl <T> Fun for T {
    type F<'a> = i32;
}

fn bug<'a, T: ?Sized + Fun<F = [u8]>>(t: Box<T>) -> &'static T::F<'a> {
    let a = [0; 1];
    let x = T::identity(&a);
    todo!()
}


fn main() {
    let x = 10;
    
    bug(Box::new(x));
}

I expected to see this happen: Throw a bunch of error becouse I wrote wrong types

Instead, this happened: LLVM ERROR: Broken function found, compilation aborted!

Meta

rustc --version --verbose:

1.47.0-nightly (2020-07-22 bbebe7351fcd29af1eb9)
Backtrace

Invalid bitcast
  %10 = bitcast { [0 x i8]*, i64 } %9 to i32*, !dbg !1289
in function _ZN10playground3bug17h799acfa1e8492d55E
LLVM ERROR: Broken function found, compilation aborted!
error: could not compile `playground`.

Note that this issue may be very similar to #68642, which has been solved

@DutchGhost DutchGhost added the C-bug Category: This is a bug. label Jul 23, 2020
@jonas-schievink jonas-schievink added F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs A-codegen Area: Code generation T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 23, 2020
@hellow554
Copy link
Contributor

hellow554 commented Jul 23, 2020

With rustc 1.46.0-nightly (346aec9b0 2020-07-11) I get an ICE

With cargo check I get the ICE below. With cargo build the LLVM ERROR from above 🤔

error: internal compiler error: impl item and trait item have different parameter counts
  |
  = note: delayed at /rustc/346aec9b02f3c74f3fce97fd6bda24709d220e49/src/librustc_session/session.rs:436:27

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at /rustc/346aec9b02f3c74f3fce97fd6bda24709d220e49/src/librustc_session/session.rs:436:27

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:367:17
stack backtrace:
   0:     0x7f5c742468a5 - backtrace::backtrace::libunwind::trace::h34afbfad7fd770fc
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1:     0x7f5c742468a5 - backtrace::backtrace::trace_unsynchronized::h460d522b1619a600
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2:     0x7f5c742468a5 - std::sys_common::backtrace::_print_fmt::ha45fac10086813b4
                               at src/libstd/sys_common/backtrace.rs:78
   3:     0x7f5c742468a5 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hde84f63fcfd0e6de
                               at src/libstd/sys_common/backtrace.rs:59
   4:     0x7f5c7428332c - core::fmt::write::h540ac4a6a1232abc
                               at src/libcore/fmt/mod.rs:1076
   5:     0x7f5c74238622 - std::io::Write::write_fmt::hc344eafd6e850b4d
                               at src/libstd/io/mod.rs:1537
   6:     0x7f5c7424b740 - std::sys_common::backtrace::_print::h4db88ff15cb5d61d
                               at src/libstd/sys_common/backtrace.rs:62
   7:     0x7f5c7424b740 - std::sys_common::backtrace::print::h5fc39e1b1f610bd3
                               at src/libstd/sys_common/backtrace.rs:49
   8:     0x7f5c7424b740 - std::panicking::default_hook::{{closure}}::h59e55edacb1d974a
                               at src/libstd/panicking.rs:198
   9:     0x7f5c7424b48c - std::panicking::default_hook::heee4c8016dfbf328
                               at src/libstd/panicking.rs:217
  10:     0x7f5c749b6489 - rustc_driver::report_ice::h779cc1b2c44c51e9
  11:     0x7f5c7424beb8 - std::panicking::rust_panic_with_hook::h8405b6301c79fb5a
                               at src/libstd/panicking.rs:530
  12:     0x7f5c77503bde - std::panicking::begin_panic::h6ea7578d4a96992b
  13:     0x7f5c77537892 - <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop::hbf11e6477c5496bc
  14:     0x7f5c749fc746 - core::ptr::drop_in_place::hf14317e84460e945
  15:     0x7f5c749ffdf6 - <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop::hc7ca667378a494ce
  16:     0x7f5c74a145fd - core::ptr::drop_in_place::h04ba5b058b45842d
  17:     0x7f5c74a0ffeb - rustc_span::with_source_map::h276db6bb3fd85930
  18:     0x7f5c74971ae6 - rustc_interface::interface::create_compiler_and_run::h7654f3523c3fe4ef
  19:     0x7f5c7499c35d - scoped_tls::ScopedKey<T>::set::hec735e67099211f0
  20:     0x7f5c749c2542 - std::sys_common::backtrace::__rust_begin_short_backtrace::hc623bbd3fa27b625
  21:     0x7f5c7497f88e - core::ops::function::FnOnce::call_once{{vtable.shim}}::he5d650d3d699089a
  22:     0x7f5c7425ac7a - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h13d34828db364579
                               at /rustc/346aec9b02f3c74f3fce97fd6bda24709d220e49/src/liballoc/boxed.rs:1081
  23:     0x7f5c7425ac7a - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::hd51b619e0f884abf
                               at /rustc/346aec9b02f3c74f3fce97fd6bda24709d220e49/src/liballoc/boxed.rs:1081
  24:     0x7f5c7425ac7a - std::sys::unix::thread::Thread::new::thread_start::h02c6e34c2c73f344
                               at src/libstd/sys/unix/thread.rs:87
  25:     0x7f5c74181422 - start_thread
  26:     0x7f5c7409fbf3 - __GI___clone
  27:                0x0 - <unknown>

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.46.0-nightly (346aec9b0 2020-07-11) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
end of query stack

@hellow554
Copy link
Contributor

At lesat they are introduced at the very same day. Not sure, why the one ICEs and the other one not. Might be worth investigating?

searched toolchains nightly-2019-01-01 through nightly-2020-07-23

Regression in nightly-2019-12-23

fetching https://static.rust-lang.org/dist/2019-12-22/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2019-12-22: 40 B / 40 B [==============================] 100.00 % 485.64 KB/s converted 2019-12-22 to fc5deca2143a448d10a1241a777275e59448c94d
fetching https://static.rust-lang.org/dist/2019-12-23/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2019-12-23: 40 B / 40 B [==============================] 100.00 % 474.24 KB/s converted 2019-12-23 to 9b98af84c4aa66392236fff59c86da2130d46d46
looking for regression commit between 2019-12-22 and 2019-12-23
fetching (via remote github) commits from max(fc5deca2143a448d10a1241a777275e59448c94d, 2019-12-20) to 9b98af84c4aa66392236fff59c86da2130d46d46
ending github query because we found starting sha: fc5deca2143a448d10a1241a777275e59448c94d
get_commits_between returning commits, len: 8
  commit[0] 2019-12-21UTC: Auto merge of #67206 - ehuss:update-cargo-books, r=dtolnay
  commit[1] 2019-12-21UTC: Auto merge of #67495 - Centril:rollup-6aer3xg, r=Centril
  commit[2] 2019-12-22UTC: Auto merge of #66932 - rust-lang:pass-check-runfail, r=petrochenkov
  commit[3] 2019-12-22UTC: Auto merge of #67486 - matthiaskrgr:submodule_upd, r=oli-obk
  commit[4] 2019-12-22UTC: Auto merge of #67505 - Centril:rollup-7win7ty, r=Centril
  commit[5] 2019-12-22UTC: Auto merge of #66931 - cjgillot:hirene-preamble, r=eddyb
  commit[6] 2019-12-22UTC: Auto merge of #65939 - anp:incremental-rustfmt-rollout, r=Mark-Simulacrum
  commit[7] 2019-12-22UTC: Auto merge of #67532 - Centril:rollup-3duj42d, r=Centril
ERROR: no commits between fc5deca2143a448d10a1241a777275e59448c94d and 9b98af84c4aa66392236fff59c86da2130d46d46 within last 167 days

@DutchGhost
Copy link
Contributor Author

@hellow554 your ice with cargo check seems similar to #68648

m-ou-se added a commit to m-ou-se/rust that referenced this issue Feb 5, 2021
…-trait-paths, r=jackh726

Generic associated types in trait paths

This is the second part of rust-lang#78978

This should fix:

Fixes rust-lang#67510
Fixes rust-lang#68648
Fixes rust-lang#68649
Fixes rust-lang#68650
Fixes rust-lang#68652
Fixes rust-lang#74684
Fixes rust-lang#76535
Fixes rust-lang#79422
Fixes rust-lang#80433

and implement the remaining functionality needed for rust-lang#44265

r? `@matthewjasper`
@bors bors closed this as completed in deec6a9 Feb 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation C-bug Category: This is a bug. F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs 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