rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.34k stars 12.72k forks source link

debugger_visualizer: ICE when changing natvis with incremental #111227

Closed ehuss closed 1 year ago

ehuss commented 1 year ago

Code

foo.rs:

#![debugger_visualizer(natvis_file = "foo.xml")]

foo.xml:

<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
    <Type Name="abc">
    </Type>
</AutoVisualizer>
  1. Run: rustc -Cincremental=incremental --crate-type=rlib foo.rs
  2. Modify foo.xml, change the type name to "abcd".
  3. Run: rustc -Cincremental=incremental --crate-type=rlib foo.rs

Meta

rustc --version --verbose:

rustc 1.71.0-nightly (473f916d8 2023-05-03)
binary: rustc
commit-hash: 473f916d836cc662c5bdbb0d40af9fb4678fab9e
commit-date: 2023-05-03
host: x86_64-pc-windows-msvc
release: 1.71.0-nightly
LLVM version: 16.0.2

Error output

error: internal compiler error: encountered incremental compilation error with debugger_visualizers(foo[38a8])
  |
  = help: This is a known issue with the compiler. Run `cargo clean` to allow your project to compile
  = note: Please follow the instructions below to create a bug report with the provided information
  = note: See <https://github.com/rust-lang/rust/issues/84970> for more information

thread 'rustc' panicked at 'Found unstable fingerprints for debugger_visualizers(foo[38a8]): [DebuggerVisualizerFile { src: [60, 63, 120, 109, 108, 32, 118, 101, 114, 115, 105, 111, 110, 61, 34, 49, 46, 48, 34, 32, 101, 110, 99, 111, 100, 105, 110, 103, 61, 34, 117, 116, 102, 45, 56, 34, 63, 62, 10, 60, 65, 117, 116, 111, 86, 105, 115, 117, 97, 108, 105, 122, 101, 114, 32, 120, 109, 108, 110, 115, 61, 34, 104, 116, 116, 112, 58, 47, 47, 115, 99, 104, 101, 109, 97, 115, 46, 109, 105, 99, 114, 111, 115, 111, 102, 116, 46, 99, 111, 109, 47, 118, 115, 116, 117, 100, 105, 111, 47, 100, 101, 98, 117, 103, 103, 101, 114, 47, 110, 97, 116, 118, 105, 115, 47, 50, 48, 49, 48, 34, 62, 10, 32, 32, 32, 32, 60, 84, 121, 112, 101, 32, 78, 97, 109, 101, 61, 34, 97, 98, 99, 100, 34, 62, 10, 32, 32, 32, 32, 60, 47, 84, 121, 112, 101, 62, 10, 60, 47, 65, 117, 116, 111, 86, 105, 115, 117, 97, 108, 105, 122, 101, 114, 62, 10], visualizer_type: Natvis }]', /rustc/473f916d836cc662c5bdbb0d40af9fb4678fab9e\compiler\rustc_query_system\src\query\plumbing.rs:734:9
stack backtrace:
   0:     0x7ffb0abb636c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h188cd6894222e83d
   1:     0x7ffb0abefa1b - core::fmt::write::hdc0a3af6fa5ac43c
   2:     0x7ffb0abab879 - <std::io::IoSliceMut as core::fmt::Debug>::fmt::h0dceb1102225fd6b
   3:     0x7ffb0abb611b - std::sys::common::alloc::realloc_fallback::h5cff4ff3fc746b16
   4:     0x7ffb0abb9939 - std::panicking::default_hook::h6769d40060bb7729
   5:     0x7ffb0abb95ef - std::panicking::default_hook::h6769d40060bb7729
   6:     0x7ffafca181be - rustc_driver_impl[b2faacf02493e161]::describe_lints
   7:     0x7ffb0abba03b - std::panicking::rust_panic_with_hook::hb856a9455c78d811
   8:     0x7ffb0abb9dbd - <std::panicking::begin_panic_handler::StrPanicPayload as core::panic::BoxMeUp>::get::hf0ca241ede9f6656
   9:     0x7ffb0abb6f99 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h188cd6894222e83d
  10:     0x7ffb0abb9ad0 - rust_begin_unwind
  11:     0x7ffb0ac22d75 - core::panicking::panic_fmt::h0c34fbe7af6ee165
  12:     0x7ffafe84faa0 - <rustc_span[dbd16f81ca8d0fd7]::def_id::LocalDefId as rustc_query_impl[3b89958a9d8885d3]::profiling_support::SpecIntoSelfProfilingString>::spec_to_self_profile_string
  13:     0x7ffafad149bc - rustc_query_impl[3b89958a9d8885d3]::plumbing::loadable_from_disk
  14:     0x7ffafac35446 - rustc_query_impl[3b89958a9d8885d3]::query_system_fns
  15:     0x7ffafc4a0003 - <rustc_metadata[e215db46a14837b0]::rmeta::encoder::EncodeContext as rustc_type_ir[b90f03a9d5693c2b]::codec::TyEncoder>::predicate_shorthands
  16:     0x7ffafae2c680 - rustc_metadata[e215db46a14837b0]::rmeta::encoder::encode_metadata
  17:     0x7ffafae2ba7e - rustc_metadata[e215db46a14837b0]::rmeta::encoder::encode_metadata
  18:     0x7ffafae31d62 - rustc_metadata[e215db46a14837b0]::fs::encode_and_write_metadata
  19:     0x7ffafa263643 - rustc_interface[aca4aa44eecc4c03]::passes::start_codegen
  20:     0x7ffafa265089 - rustc_interface[aca4aa44eecc4c03]::passes::start_codegen
  21:     0x7ffafa253727 - <rustc_interface[aca4aa44eecc4c03]::queries::Queries>::ongoing_codegen
  22:     0x7ffafa21944a - rustc_driver_impl[b2faacf02493e161]::args::arg_expand_all
  23:     0x7ffafa239f9b - <rustc_middle[d1c0634729143f8d]::ty::SymbolName as core[12e741a20c5ff342]::fmt::Display>::fmt
  24:     0x7ffafa2377c8 - rustc_driver_impl[b2faacf02493e161]::args::arg_expand_all
  25:     0x7ffafa23b7bf - <rustc_middle[d1c0634729143f8d]::ty::SymbolName as core[12e741a20c5ff342]::fmt::Display>::fmt
  26:     0x7ffb0abcd21c - std::sys::windows::thread::Thread::new::hc4a4ddeedd28bac9
  27:     0x7ffb9ee67604 - BaseThreadInitThunk
  28:     0x7ffba0e426a1 - RtlUserThreadStart

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.71.0-nightly (473f916d8 2023-05-03) running on x86_64-pc-windows-msvc

note: compiler flags: -C incremental=[REDACTED] --crate-type rlib

query stack during panic:
#0 [debugger_visualizers] looking up the debugger visualizers for this crate
end of query stack
error: aborting due to previous error
michaelwoerister commented 1 year ago

This happens because the query provider for debugger_visualizers directly reads the file contents of the visualizer file, which is not visible to dependency tracking. This can be fixed by either marking the query as eval_always since it's an input, or pulling the contents of the visualizer file into the attribute itself. The latter might be the cleaner solution but also more complicated to implement.