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: trimmed_def_paths called, diagnostics were expected but none were emitted #135289

Open
djc opened this issue Jan 9, 2025 · 13 comments · Fixed by #135310
Open

ICE: trimmed_def_paths called, diagnostics were expected but none were emitted #135289

djc opened this issue Jan 9, 2025 · 13 comments · Fixed by #135310
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-patterns Relating to patterns and pattern matching C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-diagnostics Working group: Diagnostics

Comments

@djc
Copy link
Contributor

djc commented Jan 9, 2025

beta triggered an ICE in Quinn's CI today:

https://github.com/quinn-rs/quinn/actions/runs/12691355015/job/35374229601?pr=2130

Maybe similar/related to:

Maybe a fix that could be backported?

thread 'rustc' panicked at compiler/rustc_errors/src/lib.rs:646:17:
`trimmed_def_paths` called, diagnostics were expected but none were emitted. Use `with_no_trimmed_paths` for debugging. Backtraces are currently disabled: set `RUST_BACKTRACE=1` and re-run to see where it happened.
stack backtrace:
   0:     0x7fc24a2de3ba - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h4877db58cd1f68da
   1:     0x7fc24aa135e6 - core::fmt::write::ha314f3a66d347c48
   2:     0x7fc24b903a11 - std::io::Write::write_fmt::h50f19c6ac271d942
   3:     0x7fc24a2de212 - std::sys::backtrace::BacktraceLock::print::hf8fc8e4f6df76466
   4:     0x7fc24a2e07b7 - std::panicking::default_hook::{{closure}}::hc1cbccbc75363945
   5:     0x7fc24a2e05a0 - std::panicking::default_hook::ha6ac61b9282038d9
   6:     0x7fc249453168 - std[a5195d1e2fc22c41]::panicking::update_hook::<alloc[20639d31ccb56773]::boxed::Box<rustc_driver_impl[5024ff76ded81fa1]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7fc24a2e1003 - std::panicking::rust_panic_with_hook::h5663cbee266e1761
   8:     0x7fc24a2e0cfa - std::panicking::begin_panic_handler::{{closure}}::hbbe6da1959d575ac
   9:     0x7fc24a2de889 - std::sys::backtrace::__rust_end_short_backtrace::h8c70aabd292ca3dd
  10:     0x7fc24a2e09bd - rust_begin_unwind
  11:     0x7fc246f9ff80 - core::panicking::panic_fmt::h044f8a6ac8b759ab
  12:     0x7fc24b850471 - <rustc_errors[697e64861a5c752e]::DiagCtxtInner as core[355654ca938a17d7]::ops::drop::Drop>::drop
  13:     0x7fc24b850f9c - core[355654ca938a17d7]::ptr::drop_in_place::<rustc_errors[697e64861a5c752e]::DiagCtxt>
  14:     0x7fc24b9a551a - core[355654ca938a17d7]::ptr::drop_in_place::<rustc_session[7408041faf332997]::parse::ParseSess>
  15:     0x7fc24b9a64a0 - core[355654ca938a17d7]::ptr::drop_in_place::<rustc_interface[2b78e7c3f7f2a3ff]::interface::Compiler>
  16:     0x7fc24b9ada79 - rustc_interface[2b78e7c3f7f2a3ff]::interface::run_compiler::<(), rustc_driver_impl[5024ff76ded81fa1]::run_compiler::{closure#0}>::{closure#1}
  17:     0x7fc24b853b95 - std[a5195d1e2fc22c41]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[2b78e7c3f7f2a3ff]::util::run_in_thread_with_globals<rustc_interface[2b78e7c3f7f2a3ff]::util::run_in_thread_pool_with_globals<rustc_interface[2b78e7c3f7f2a3ff]::interface::run_compiler<(), rustc_driver_impl[5024ff76ded81fa1]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  18:     0x7fc24b854048 - <<std[a5195d1e2fc22c41]::thread::Builder>::spawn_unchecked_<rustc_interface[2b78e7c3f7f2a3ff]::util::run_in_thread_with_globals<rustc_interface[2b78e7c3f7f2a3ff]::util::run_in_thread_pool_with_globals<rustc_interface[2b78e7c3f7f2a3ff]::interface::run_compiler<(), rustc_driver_impl[5024ff76ded81fa1]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[355654ca938a17d7]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  19:     0x7fc24b855601 - std::sys::pal::unix::thread::Thread::new::thread_start::h535af24502242ac5
  20:     0x7fc245a9ca94 - <unknown>
  21:     0x7fc245b29c3c - <unknown>
  22:                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: rustc 1.85.0-beta.1 (e30eefff4 2025-01-08) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2

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

query stack during panic:
end of query stack
error: could not compile `quinn-proto` (lib test)

Caused by:
  process didn't exit successfully: `/home/runner/.rustup/toolchains/beta-x86_64-unknown-linux-gnu/bin/rustc --crate-name quinn_proto --edition=2021 quinn-proto/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --warn=unexpected_cfgs --check-cfg 'cfg(fuzzing)' --test --cfg 'feature="default"' --cfg 'feature="log"' --cfg 'feature="platform-verifier"' --cfg 'feature="ring"' --cfg 'feature="rustls-ring"' --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values("arbitrary", "aws-lc-rs", "aws-lc-rs-fips", "default", "log", "platform-verifier", "ring", "rustls", "rustls-aws-lc-rs", "rustls-aws-lc-rs-fips", "rustls-log", "rustls-ring"))' -C metadata=e4cd9ebb7814c565 -C extra-filename=-875e02898ea8dd6b --out-dir /home/runner/work/quinn/quinn/target/debug/deps -L dependency=/home/runner/work/quinn/quinn/target/debug/deps --extern assert_matches=/home/runner/work/quinn/quinn/target/debug/deps/libassert_matches-ff215179dd669654.rlib --extern bytes=/home/runner/work/quinn/quinn/target/debug/deps/libbytes-a85ea1e0de84b215.rlib --extern hex_literal=/home/runner/work/quinn/quinn/target/debug/deps/libhex_literal-26f17529c9d73dcc.rlib --extern lazy_static=/home/runner/work/quinn/quinn/target/debug/deps/liblazy_static-b03541b63c18dba7.rlib --extern rand=/home/runner/work/quinn/quinn/target/debug/deps/librand-717c8c34580787c0.rlib --extern rcgen=/home/runner/work/quinn/quinn/target/debug/deps/librcgen-86629bfa01ffb0b4.rlib --extern ring=/home/runner/work/quinn/quinn/target/debug/deps/libring-b326a68ecfa48aef.rlib --extern rustc_hash=/home/runner/work/quinn/quinn/target/debug/deps/librustc_hash-311bd3609ea046c6.rlib --extern rustls=/home/runner/work/quinn/quinn/target/debug/deps/librustls-df6c75c11fb1ff22.rlib --extern rustls_platform_verifier=/home/runner/work/quinn/quinn/target/debug/deps/librustls_platform_verifier-11787e01b1085472.rlib --extern slab=/home/runner/work/quinn/quinn/target/debug/deps/libslab-3c03d7cf5b378de6.rlib --extern thiserror=/home/runner/work/quinn/quinn/target/debug/deps/libthiserror-efb27899156c3206.rlib --extern tinyvec=/home/runner/work/quinn/quinn/target/debug/deps/libtinyvec-1f34b1656bcd04e6.rlib --extern tracing=/home/runner/work/quinn/quinn/target/debug/deps/libtracing-908c8b1357dbbdf0.rlib --extern tracing_subscriber=/home/runner/work/quinn/quinn/target/debug/deps/libtracing_subscriber-d313c5fd47fc560a.rlib --extern wasm_bindgen_test=/home/runner/work/quinn/quinn/target/debug/deps/libwasm_bindgen_test-35a5da5beb78a7c9.rlib -L native=/home/runner/work/quinn/quinn/target/debug/build/ring-f079ed4dd15e693d/out` (exit status: 101)
@djc djc 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 Jan 9, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 9, 2025
@lqd
Copy link
Member

lqd commented Jan 9, 2025

What are the steps to reproduce? cargo check on quinn?

@djc
Copy link
Contributor Author

djc commented Jan 9, 2025

CI ran cargo build --all-targets against the Quinn repo.

@lqd
Copy link
Member

lqd commented Jan 9, 2025

Thanks you saved me a click 👍.

Maybe a fix that could be backported?

This is still happening on nightly with cargo check --all-targets so there's unfortunately nothing to backport yet.

Bisection points at #132658 but it's unclear whether that's actually correct yet -- I'll cc the author @estebank for due diligence -- but such issues are sometimes easy so I'll see if I have the time to look into it soon.

@lqd lqd added A-diagnostics Area: Messages for errors, warnings, and lints WG-diagnostics Working group: Diagnostics A-patterns Relating to patterns and pattern matching and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jan 9, 2025
@lqd
Copy link
Member

lqd commented Jan 9, 2025

Some context for esteban:

  • I believe this is triggered here https://github.com/quinn-rs/quinn/blob/fbc795e3cea722996232f2c853772390e05d51fe/quinn-proto/src/tests/mod.rs#L1638-L1641
  • it seems some match arms are thought as unreachable, report_unreachable_pattern calls the const typo check from Detect const in pattern with typo #132658 -- I don't know for sure if there are false positives in the unreachable arm computation (there must be), but overall 2 match arms pass through diagnostics as unreachable in that crate and its tests.
  • however, on the parent commit of the rollup where this landed, no patterns related warnings are emitted, and it seems no #[allow(unreachable_patterns) are present in the repo or the dependency where that macro comes from so find_fallback_pattern_typo runs.
  • I don't know if some later process eats them or something, but this lack of warnings causes the ICE of course

@estebank
Copy link
Contributor

estebank commented Jan 9, 2025

I think that we can side-step the issue quickly by removing the call to with_no_trimmed_paths!. accessible_paths could instead collect Ty<'_>s and that might work too.

@lqd
Copy link
Member

lqd commented Jan 9, 2025

There’s no rush, right?

@estebank
Copy link
Contributor

estebank commented Jan 9, 2025

I couldn't build a minimal repro to add to the test suite, but #135310 solves the ICE.

@estebank
Copy link
Contributor

The ICE occurs due to some incorrect behavior in reachability checking of the pattern at quinn-proto/src/tests/mod.rs:1640:9. Consider annotating #[allow(unreachable_patterns)] on that assert_matches as a temporary measure to get around the issues on CI.

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Jan 19, 2025
Always force non-trimming of path in `unreachable_patterns` lint

Creating a "trimmed DefID path" when no error is being emitted is an ICE (on purpose). If we create a trimmed path for a lint that is then silenced before being emitted causes a known ICE. This side-steps the issue by always using `with_no_trimmed_path!`.

This was verified to fix https://github.com/quinn-rs/quinn/, but couldn't write a repro case for the test suite.

Fix rust-lang#135289.
jieyouxu added a commit to jieyouxu/rust that referenced this issue Jan 20, 2025
Always force non-trimming of path in `unreachable_patterns` lint

Creating a "trimmed DefID path" when no error is being emitted is an ICE (on purpose). If we create a trimmed path for a lint that is then silenced before being emitted causes a known ICE. This side-steps the issue by always using `with_no_trimmed_path!`.

This was verified to fix https://github.com/quinn-rs/quinn/, but couldn't write a repro case for the test suite.

Fix rust-lang#135289.
@bors bors closed this as completed in 93a1950 Jan 20, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jan 20, 2025
Rollup merge of rust-lang#135310 - estebank:issue-135289, r=Nadrieril

Always force non-trimming of path in `unreachable_patterns` lint

Creating a "trimmed DefID path" when no error is being emitted is an ICE (on purpose). If we create a trimmed path for a lint that is then silenced before being emitted causes a known ICE. This side-steps the issue by always using `with_no_trimmed_path!`.

This was verified to fix https://github.com/quinn-rs/quinn/, but couldn't write a repro case for the test suite.

Fix rust-lang#135289.
@lqd
Copy link
Member

lqd commented Jan 20, 2025

Reopening to track beta backport

@lqd lqd reopened this Jan 20, 2025
@estebank
Copy link
Contributor

Let's keep it open even after backport for E-needs-test's sake.

@estebank estebank added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jan 20, 2025
@lqd lqd added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Jan 20, 2025
@lqd
Copy link
Member

lqd commented Jan 21, 2025

@djc btw, in the piece of code where I found the ICE and linked earlier: the assert_matches! is on _next_retire_prior_to, but is it supposed to match the local var next_retire_prior_to? edit: maybe not, but this macro seems "interesting" if you pass it something that doesn't exist.

@djc
Copy link
Contributor Author

djc commented Jan 21, 2025

@lqd huh, thanks for calling that out -- fixing it.

@lqd
Copy link
Member

lqd commented Jan 21, 2025

This ICE resisted minimization a lot. Obviously any error is a no no, but it was the same for many warnings as well: any unused variable, useless mut, unused import, etc and the ICE disappears like a frightened tortoise 🐢. Once I discovered that, things became less unpleasant.

  • dependency (edition <2021)
#[macro_export]
macro_rules! assert_matches {
    ( $e:expr , $($pat:pat)|+ ) => {
        match $e {
            $($pat)|+ => (),
            _ => (),
        }
    };
}
  • repro
const _A: u64 = 0;
pub fn f() -> u64 {
    0
}
fn main() {
    fake_matches::assert_matches!(f(), _non_existent);
}

I've opened #135833 to add this as a test for now, but the fix should now be easier to clean up.

@lqd lqd added S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue and removed E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Jan 21, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 21, 2025
Add fixme and test for issue rust-lang#135289

This PR:
- adds a test minimizing issue rust-lang#135289 for PR rust-lang#135310
- adds a fixme about the suboptimal fix for the ICE

I've verified the test indeed ICEs with 3f2f695 reverted.

r? `@estebank`
bors added a commit to rust-lang-ci/rust that referenced this issue Jan 22, 2025
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#132232 (CI: build FreeBSD artifacts on FreeBSD 13.4)
 - rust-lang#135706 (Move `supertrait_def_ids` into the elaborate module like all other fns)
 - rust-lang#135750 (Add an example of using `carrying_mul_add` to write wider multiplication)
 - rust-lang#135793 (Ignore `mermaid.min.js`)
 - rust-lang#135810 (Add Kobzol on vacation)
 - rust-lang#135821 (fix OsString::from_encoded_bytes_unchecked description)
 - rust-lang#135824 (tests: delete `cat-and-grep-sanity-check`)
 - rust-lang#135833 (Add fixme and test for issue rust-lang#135289)

Failed merges:

 - rust-lang#135816 (Use `structurally_normalize` instead of manual `normalizes-to` goals in alias relate errors)

r? `@ghost`
`@rustbot` modify labels: rollup
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jan 22, 2025
Rollup merge of rust-lang#135833 - lqd:add-ice-test, r=compiler-errors

Add fixme and test for issue rust-lang#135289

This PR:
- adds a test minimizing issue rust-lang#135289 for PR rust-lang#135310
- adds a fixme about the suboptimal fix for the ICE

I've verified the test indeed ICEs with 3f2f695 reverted.

r? `@estebank`
cuviper pushed a commit to cuviper/rust that referenced this issue Jan 24, 2025
Creating a "trimmed DefID path" when no error is being emitted is an ICE (on purpose). If we create a trimmed path for a lint that is then silenced before being emitted causes a known ICE. This side-steps the issue by always using `with_no_trimmed_path!`.

This was verified to fix https://github.com/quinn-rs/quinn/, but couldn't write a repro case for the test suite.

Fix rust-lang#135289.

(cherry picked from commit 93a1950)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-patterns Relating to patterns and pattern matching C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-diagnostics Working group: Diagnostics
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants