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

cannot create local mono-item for DefId #73537

Closed
alecmocatta opened this issue Jun 20, 2020 · 12 comments
Closed

cannot create local mono-item for DefId #73537

alecmocatta opened this issue Jun 20, 2020 · 12 comments
Labels
A-codegen Area: Code generation C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ I-monomorphization Issue: An error at monomorphization time. ICEBreaker-Cleanup-Crew Helping to "clean up" bugs with minimal examples and bisections P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@alecmocatta
Copy link
Contributor

Branch ice of the Amadeus repo triggers an ICE. The ICE can be avoided by adding #[inline(always)] to the function identified in the error message.

git clone https://github.com/constellation-rs/amadeus.git
cd amadeus
git checkout ice
cargo +nightly-2020-06-10 test --features "aws"

Meta

With nightly-2019-10-15 two functions triggered this (see the most recent commit on the ice branch). With nightly-2020-06-10 only one triggers it. My guess is inlining heuristics or similar have changed, making one of the functions inline thus avoiding triggering the ICE?

Error output

error: internal compiler error: src/librustc_mir/monomorphize/collector.rs:766: cannot create local mono-item for DefId(112:77 ~ amadeus_aws[d447]::cloudfront[0]::{{impl}}[2]::from_line[0])
Backtrace

$ RUST_BACKTRACE=1 cargo test --features "aws"
   Compiling amadeus v0.2.0 (/Users/alecmocatta/Documents/deploy/amadeus)
error: internal compiler error: src/librustc_mir/monomorphize/collector.rs:766: cannot create local mono-item for DefId(112:77 ~ amadeus_aws[d447]::cloudfront[0]::{{impl}}[2]::from_line[0])

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:907:9
stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: std::io::Write::write_fmt
   3: std::panicking::default_hook::{{closure}}
   4: std::panicking::default_hook
   5: rustc_driver::report_ice
   6: std::panicking::rust_panic_with_hook
   7: std::panicking::begin_panic
   8: rustc_errors::HandlerInner::bug
   9: rustc_errors::Handler::bug
  10: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}
  11: rustc_middle::ty::context::tls::with_opt::{{closure}}
  12: rustc_middle::ty::context::tls::with_opt
  13: rustc_middle::util::bug::opt_span_bug_fmt
  14: rustc_middle::util::bug::bug_fmt
  15: rustc_mir::monomorphize::collector::should_monomorphize_locally
  16: <rustc_mir::monomorphize::collector::MirNeighborCollector as rustc_middle::mir::visit::Visitor>::visit_terminator_kind
  17: rustc_mir::monomorphize::collector::collect_neighbours
  18: rustc_data_structures::stack::ensure_sufficient_stack
  19: rustc_mir::monomorphize::collector::collect_items_rec
  20: rustc_mir::monomorphize::collector::collect_items_rec
  21: rustc_mir::monomorphize::collector::collect_items_rec
  22: rustc_mir::monomorphize::collector::collect_items_rec
  23: rustc_mir::monomorphize::collector::collect_items_rec
  24: rustc_mir::monomorphize::collector::collect_items_rec
  25: rustc_mir::monomorphize::collector::collect_items_rec
  26: rustc_mir::monomorphize::collector::collect_items_rec
  27: rustc_mir::monomorphize::collector::collect_items_rec
  28: rustc_mir::monomorphize::collector::collect_items_rec
  29: rustc_mir::monomorphize::collector::collect_items_rec
  30: rustc_mir::monomorphize::collector::collect_items_rec
  31: rustc_mir::monomorphize::collector::collect_items_rec
  32: rustc_mir::monomorphize::collector::collect_items_rec
  33: rustc_mir::monomorphize::collector::collect_items_rec
  34: rustc_mir::monomorphize::collector::collect_items_rec
  35: rustc_mir::monomorphize::collector::collect_items_rec
  36: rustc_mir::monomorphize::collector::collect_items_rec
  37: rustc_mir::monomorphize::collector::collect_items_rec
  38: rustc_mir::monomorphize::collector::collect_items_rec
  39: rustc_mir::monomorphize::collector::collect_items_rec
  40: rustc_mir::monomorphize::collector::collect_items_rec
  41: rustc_mir::monomorphize::collector::collect_items_rec
  42: rustc_mir::monomorphize::collector::collect_items_rec
  43: rustc_mir::monomorphize::collector::collect_items_rec
  44: rustc_mir::monomorphize::collector::collect_items_rec
  45: rustc_mir::monomorphize::collector::collect_items_rec
  46: rustc_mir::monomorphize::collector::collect_items_rec
  47: rustc_mir::monomorphize::collector::collect_items_rec
  48: rustc_mir::monomorphize::collector::collect_items_rec
  49: rustc_mir::monomorphize::collector::collect_items_rec
  50: rustc_mir::monomorphize::collector::collect_items_rec
  51: rustc_mir::monomorphize::collector::collect_items_rec
  52: rustc_mir::monomorphize::collector::collect_items_rec
  53: rustc_mir::monomorphize::collector::collect_items_rec
  54: rustc_mir::monomorphize::collector::collect_items_rec
  55: rustc_mir::monomorphize::collector::collect_items_rec
  56: rustc_mir::monomorphize::collector::collect_items_rec
  57: rustc_mir::monomorphize::collector::collect_items_rec
  58: rustc_mir::monomorphize::collector::collect_items_rec
  59: rustc_mir::monomorphize::collector::collect_items_rec
  60: rustc_mir::monomorphize::collector::collect_items_rec
  61: rustc_mir::monomorphize::collector::collect_items_rec
  62: rustc_mir::monomorphize::collector::collect_items_rec
  63: rustc_mir::monomorphize::collector::collect_items_rec
  64: rustc_mir::monomorphize::collector::collect_items_rec
  65: rustc_mir::monomorphize::collector::collect_items_rec
  66: rustc_mir::monomorphize::collector::collect_items_rec
  67: rustc_mir::monomorphize::collector::collect_items_rec
  68: rustc_mir::monomorphize::collector::collect_items_rec
  69: rustc_mir::monomorphize::collector::collect_items_rec
  70: rustc_mir::monomorphize::collector::collect_items_rec
  71: rustc_mir::monomorphize::collector::collect_items_rec
  72: rustc_mir::monomorphize::collector::collect_items_rec
  73: rustc_mir::monomorphize::collector::collect_items_rec
  74: rustc_mir::monomorphize::collector::collect_items_rec
  75: rustc_mir::monomorphize::collector::collect_items_rec
  76: rustc_mir::monomorphize::collector::collect_items_rec
  77: rustc_mir::monomorphize::collector::collect_items_rec
  78: rustc_mir::monomorphize::collector::collect_items_rec
  79: rustc_mir::monomorphize::collector::collect_items_rec
  80: rustc_mir::monomorphize::collector::collect_items_rec
  81: rustc_mir::monomorphize::collector::collect_items_rec
  82: rustc_mir::monomorphize::collector::collect_items_rec
  83: rustc_mir::monomorphize::collector::collect_items_rec
  84: rustc_mir::monomorphize::collector::collect_items_rec
  85: rustc_mir::monomorphize::collector::collect_items_rec
  86: rustc_mir::monomorphize::collector::collect_items_rec
  87: rustc_mir::monomorphize::collector::collect_items_rec
  88: rustc_mir::monomorphize::collector::collect_items_rec
  89: rustc_mir::monomorphize::collector::collect_items_rec
  90: rustc_mir::monomorphize::collector::collect_items_rec
  91: rustc_mir::monomorphize::collector::collect_items_rec
  92: rustc_mir::monomorphize::collector::collect_items_rec
  93: rustc_mir::monomorphize::collector::collect_items_rec
  94: rustc_mir::monomorphize::collector::collect_items_rec
  95: rustc_mir::monomorphize::collector::collect_items_rec
  96: rustc_mir::monomorphize::collector::collect_items_rec
  97: rustc_mir::monomorphize::collector::collect_items_rec
  98: rustc_mir::monomorphize::collector::collect_items_rec
  99: rustc_mir::monomorphize::collector::collect_items_rec
 100: rustc_mir::monomorphize::collector::collect_items_rec
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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 (feb3536eb 2020-06-09) running on x86_64-apple-darwin

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental -C target-cpu=native

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

query stack during panic:
#0 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: aborting due to previous error

error: could not compile `amadeus`.

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: internal compiler error: src/librustc_mir/monomorphize/collector.rs:766: cannot create local mono-item for DefId(112:77 ~ amadeus_aws[d447]::cloudfront[0]::{{impl}}[2]::from_line[0])

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:907:9
stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: std::io::Write::write_fmt
   3: std::panicking::default_hook::{{closure}}
   4: std::panicking::default_hook
   5: rustc_driver::report_ice
   6: std::panicking::rust_panic_with_hook
   7: std::panicking::begin_panic
   8: rustc_errors::HandlerInner::bug
   9: rustc_errors::Handler::bug
  10: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}
  11: rustc_middle::ty::context::tls::with_opt::{{closure}}
  12: rustc_middle::ty::context::tls::with_opt
  13: rustc_middle::util::bug::opt_span_bug_fmt
  14: rustc_middle::util::bug::bug_fmt
  15: rustc_mir::monomorphize::collector::should_monomorphize_locally
  16: <rustc_mir::monomorphize::collector::MirNeighborCollector as rustc_middle::mir::visit::Visitor>::visit_terminator_kind
  17: rustc_mir::monomorphize::collector::collect_neighbours
  18: rustc_data_structures::stack::ensure_sufficient_stack
  19: rustc_mir::monomorphize::collector::collect_items_rec
  20: rustc_mir::monomorphize::collector::collect_items_rec
  21: rustc_mir::monomorphize::collector::collect_items_rec
  22: rustc_mir::monomorphize::collector::collect_items_rec
  23: rustc_mir::monomorphize::collector::collect_items_rec
  24: rustc_mir::monomorphize::collector::collect_items_rec
  25: rustc_mir::monomorphize::collector::collect_items_rec
  26: rustc_mir::monomorphize::collector::collect_items_rec
  27: rustc_mir::monomorphize::collector::collect_items_rec
  28: rustc_mir::monomorphize::collector::collect_items_rec
  29: rustc_mir::monomorphize::collector::collect_items_rec
  30: rustc_mir::monomorphize::collector::collect_items_rec
  31: rustc_mir::monomorphize::collector::collect_items_rec
  32: rustc_mir::monomorphize::collector::collect_items_rec
  33: rustc_mir::monomorphize::collector::collect_items_rec
  34: rustc_mir::monomorphize::collector::collect_items_rec
  35: rustc_mir::monomorphize::collector::collect_items_rec
  36: rustc_mir::monomorphize::collector::collect_items_rec
  37: rustc_mir::monomorphize::collector::collect_items_rec
  38: rustc_mir::monomorphize::collector::collect_items_rec
  39: rustc_mir::monomorphize::collector::collect_items_rec
  40: rustc_mir::monomorphize::collector::collect_items_rec
  41: rustc_mir::monomorphize::collector::collect_items_rec
  42: rustc_mir::monomorphize::collector::collect_items_rec
  43: rustc_mir::monomorphize::collector::collect_items_rec
  44: rustc_mir::monomorphize::collector::collect_items_rec
  45: rustc_mir::monomorphize::collector::collect_items_rec
  46: rustc_mir::monomorphize::collector::collect_items_rec
  47: rustc_mir::monomorphize::collector::collect_items_rec
  48: rustc_mir::monomorphize::collector::collect_items_rec
  49: rustc_mir::monomorphize::collector::collect_items_rec
  50: rustc_mir::monomorphize::collector::collect_items_rec
  51: rustc_mir::monomorphize::collector::collect_items_rec
  52: rustc_mir::monomorphize::collector::collect_items_rec
  53: rustc_mir::monomorphize::collector::collect_items_rec
  54: rustc_mir::monomorphize::collector::collect_items_rec
  55: rustc_mir::monomorphize::collector::collect_items_rec
  56: rustc_mir::monomorphize::collector::collect_items_rec
  57: rustc_mir::monomorphize::collector::collect_items_rec
  58: rustc_mir::monomorphize::collector::collect_items_rec
  59: rustc_mir::monomorphize::collector::collect_items_rec
  60: rustc_mir::monomorphize::collector::collect_items_rec
  61: rustc_mir::monomorphize::collector::collect_items_rec
  62: rustc_mir::monomorphize::collector::collect_items_rec
  63: rustc_mir::monomorphize::collector::collect_items_rec
  64: rustc_mir::monomorphize::collector::collect_items_rec
  65: rustc_mir::monomorphize::collector::collect_items_rec
  66: rustc_mir::monomorphize::collector::collect_items_rec
  67: rustc_mir::monomorphize::collector::collect_items_rec
  68: rustc_mir::monomorphize::collector::collect_items_rec
  69: rustc_mir::monomorphize::collector::collect_items_rec
  70: rustc_mir::monomorphize::collector::collect_items_rec
  71: rustc_mir::monomorphize::collector::collect_items_rec
  72: rustc_mir::monomorphize::collector::collect_items_rec
  73: rustc_mir::monomorphize::collector::collect_items_rec
  74: rustc_mir::monomorphize::collector::collect_items_rec
  75: rustc_mir::monomorphize::collector::collect_items_rec
  76: rustc_mir::monomorphize::collector::collect_items_rec
  77: rustc_mir::monomorphize::collector::collect_items_rec
  78: rustc_mir::monomorphize::collector::collect_items_rec
  79: rustc_mir::monomorphize::collector::collect_items_rec
  80: rustc_mir::monomorphize::collector::collect_items_rec
  81: rustc_mir::monomorphize::collector::collect_items_rec
  82: rustc_mir::monomorphize::collector::collect_items_rec
  83: rustc_mir::monomorphize::collector::collect_items_rec
  84: rustc_mir::monomorphize::collector::collect_items_rec
  85: rustc_mir::monomorphize::collector::collect_items_rec
  86: rustc_mir::monomorphize::collector::collect_items_rec
  87: rustc_mir::monomorphize::collector::collect_items_rec
  88: rustc_mir::monomorphize::collector::collect_items_rec
  89: rustc_mir::monomorphize::collector::collect_items_rec
  90: rustc_mir::monomorphize::collector::collect_items_rec
  91: rustc_mir::monomorphize::collector::collect_items_rec
  92: rustc_mir::monomorphize::collector::collect_items_rec
  93: rustc_mir::monomorphize::collector::collect_items_rec
  94: rustc_mir::monomorphize::collector::collect_items_rec
  95: rustc_mir::monomorphize::collector::collect_items_rec
  96: rustc_mir::monomorphize::collector::collect_items_rec
  97: rustc_mir::monomorphize::collector::collect_items_rec
  98: rustc_mir::monomorphize::collector::collect_items_rec
  99: rustc_mir::monomorphize::collector::collect_items_rec
 100: rustc_mir::monomorphize::collector::collect_items_rec
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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 (feb3536eb 2020-06-09) running on x86_64-apple-darwin

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental -C target-cpu=native

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

query stack during panic:
#0 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: aborting due to previous error

@alecmocatta alecmocatta 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 Jun 20, 2020
@jonas-schievink jonas-schievink added A-codegen Area: Code generation I-prioritize Issue: Indicates that prioritization has been requested for this issue. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Jun 20, 2020
@LeSeulArtichaut LeSeulArtichaut added the I-monomorphization Issue: An error at monomorphization time. label Jun 20, 2020
@LeSeulArtichaut
Copy link
Contributor

Let’s try to find an MCVE.
@rustbot ping cleanup

@rustbot
Copy link
Collaborator

rustbot commented Jun 20, 2020

Hey Cleanup Crew ICE-breakers! This bug has been identified as a good
"Cleanup ICE-breaking candidate". In case it's useful, here are some
instructions for tackling these sorts of bugs. Maybe take a look?
Thanks! <3

cc @AminArria @camelid @chrissimpkins @contrun @DutchGhost @elshize @ethanboxx @h-michael @HallerPatrick @hdhoang @hellow554 @imtsuki @kanru @KarlK90 @LeSeulArtichaut @MAdrianMattocks @matheus-consoli @mental32 @nmccarty @Noah-Kennedy @pard68 @PeytonT @pierreN @Redblueflame @RobbieClarken @RobertoSnap @robjtede @SarthakSingh31 @senden9 @shekohex @sinato @spastorino @turboladen @woshilapin @yerke

@rustbot rustbot added the ICEBreaker-Cleanup-Crew Helping to "clean up" bugs with minimal examples and bisections label Jun 20, 2020
@spastorino
Copy link
Member

Would be nice to find an MCVE and this also seems to be a regression, would be nice to find when this has regressed.

@spastorino
Copy link
Member

Prioritizing it as P-critical for now to raise awareness until we have a better understanding of this. This was discussed briefly on this Zulip topic.

@spastorino spastorino added P-critical Critical priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jun 24, 2020
@hellow554
Copy link
Contributor

hellow554 commented Jun 25, 2020

I was on it, but Amadeus is a massive code base and it's not easy to isolate dependencies (especially because ! needs some improvements in this regards ;) ), but I'll try it again today, to see if there's something.

@hellow554
Copy link
Contributor

Okay, so here's some information.

rustc 1.46.0-nightly (a37c32e2d 2020-06-11) cannot build the project, because of:

error: failed to download `delegate v0.4.3`

Caused by:
  unable to get packages from source

Caused by:
  failed to parse manifest at `/home/marcel/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/delegate-0.4.3/Cargo.toml`

Caused by:
  readme file with name 'README.md' was not found

rustc 1.46.0-nightly (f4fbb9311 2020-06-12) will panic with:

error: internal compiler error: src/librustc_traits/normalize_erasing_regions.rs:37: could not fully normalize `<A as sealed::SimdArray>::Tuple`

so, that's a different ICE?

And again starting with rustc 1.46.0-nightly (2d8bd9b74 2020-06-19) the project will compile just fine, so I guess it has been fixed in the mean time? I'm sure this needs a test, but as said, the codebase is enormous.

@alecmocatta
Copy link
Contributor Author

@hellow554 The could not fully normalize <A as sealed::SimdArray>::Tuple ICE was fixed by #73257. I didn't notice the delegate ICE myself.

You're right that as of nightly-2020-06-20 the cannot create local mono-item for DefId ICE isn't reproducing.

As I mentioned I observed two functions triggering it on 2019-10-15, and only one on 2020-06-10. Now zero on 2020-06-20. Either it was fixed or masked some time in those 10 days.

I'll remove the workaround from master so I'll notice if any future nightlies re-trigger this and update this issue.

Until then, shall I leave this issue open as the ICE might not have been fixed, just masked, or close it as it's no longer reproducable on current nightly?

@LeSeulArtichaut
Copy link
Contributor

I think we will need a test for this anyway.

@LeSeulArtichaut LeSeulArtichaut added E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. and removed E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Jun 25, 2020
@spastorino spastorino added P-medium Medium priority and removed P-critical Critical priority labels Jul 2, 2020
@spastorino
Copy link
Member

Lowered to P-medium, priority of adding a test for it :).

@JohnTitor JohnTitor added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Jul 10, 2020
@connorskees
Copy link
Contributor

This one is hard! I've managed to get it down from 50,000 to around 1,200 lines and remove most dependencies (notably, tokio and futures remain), but it's still very difficult to remove the remaining lines.

If anyone else wants to try to reduce it further, I've put the repository here:
https://github.com/connorskees/rust-issue-73537

git clone https://github.com/connorskees/rust-issue-73537
cd rust-issue-73537
cargo +nightly-2020-06-10 test --features "aws"

@tmiasko
Copy link
Contributor

tmiasko commented Jul 14, 2020

Looks like the same issue as #69785, which is already minimized. The use of an
existential type in an associated type position, which happens to reference a
function which isn't otherwise externally reachable. The MIR of the function is
incorrectly omitted, despite the fact it might be referenced externally.

@oli-obk
Copy link
Contributor

oli-obk commented Feb 19, 2021

closing as duplicate

@oli-obk oli-obk closed this as completed Feb 19, 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. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ I-monomorphization Issue: An error at monomorphization time. ICEBreaker-Cleanup-Crew Helping to "clean up" bugs with minimal examples and bisections P-medium Medium priority 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

10 participants