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

Building icu_locid with -Z save-analysis causes ICE #2971

Closed
makotokato opened this issue Jan 10, 2023 · 8 comments
Closed

Building icu_locid with -Z save-analysis causes ICE #2971

makotokato opened this issue Jan 10, 2023 · 8 comments
Labels
R-as-designed Resolution: By design principles, this won't be fixed

Comments

@makotokato
Copy link
Member

makotokato commented Jan 10, 2023

Although this is rust compiler bug (similar to rust-lang/rust#97671), I file an issue to ICU4X. (if we have a workaround on ICU4X side, I think that it is better).

When building icu_locid with -Z save-analysis, rustc causes ICE. Firefox CI uses -Z save-analysis for searchfox (Firefox's source code indexer) task.

STEP

RUSTFLAGS="-Z save-analysis" cargo nightly build -v in components/locid

RESULT

   Compiling icu_locid v1.0.0 (/other/icu4x/components/locid)
     Running `rustc --crate-name icu_locid --edition=2021 components/locid/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=135 --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' -C metadata=03d7c6515c4004e4 -C extra-filename=-03d7c6515c4004e4 --out-dir /other/icu4x/target/debug/deps -C incremental=/other/icu4x/target/debug/incremental -L dependency=/other/icu4x/target/debug/deps --extern displaydoc=/other/icu4x/target/debug/deps/libdisplaydoc-1a156e6506d0f61a.so --extern litemap=/other/icu4x/target/debug/deps/liblitemap-48001ada33b24860.rmeta --extern tinystr=/other/icu4x/target/debug/deps/libtinystr-fccb1b127c9b0803.rmeta --extern writeable=/other/icu4x/target/debug/deps/libwriteable-3f9fd8661d7c12e0.rmeta -Z save-analysis`
thread 'rustc' panicked at '`SaveContext::typeck_results` called outside of body', compiler/rustc_save_analysis/src/lib.rs:520:23
stack backtrace:
   0:     0x7f34c496531a - std::backtrace_rs::backtrace::libunwind::trace::hdca77ab3bec44471
                               at /rustc/3020239de947ec52677e9b4e853a6a9fc073d1f9/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f34c496531a - std::backtrace_rs::backtrace::trace_unsynchronized::hfe4f6d6ad029d217
                               at /rustc/3020239de947ec52677e9b4e853a6a9fc073d1f9/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f34c496531a - std::sys_common::backtrace::_print_fmt::h4c8d5d821895e43e
                               at /rustc/3020239de947ec52677e9b4e853a6a9fc073d1f9/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f34c496531a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h5adb97f2e886759a
                               at /rustc/3020239de947ec52677e9b4e853a6a9fc073d1f9/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f34c49c855e - core::fmt::write::h828c59fc78b17391
                               at /rustc/3020239de947ec52677e9b4e853a6a9fc073d1f9/library/core/src/fmt/mod.rs:1208:17
   5:     0x7f34c49557f5 - std::io::Write::write_fmt::h0c8f0d571d31812a
                               at /rustc/3020239de947ec52677e9b4e853a6a9fc073d1f9/library/std/src/io/mod.rs:1682:15
   6:     0x7f34c49650e5 - std::sys_common::backtrace::_print::had90567330241219
                               at /rustc/3020239de947ec52677e9b4e853a6a9fc073d1f9/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f34c49650e5 - std::sys_common::backtrace::print::hbbbec0560e502261
                               at /rustc/3020239de947ec52677e9b4e853a6a9fc073d1f9/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f34c4967eaf - std::panicking::default_hook::{{closure}}::h2bb3889378be62ea
                               at /rustc/3020239de947ec52677e9b4e853a6a9fc073d1f9/library/std/src/panicking.rs:267:22
   9:     0x7f34c4967beb - std::panicking::default_hook::hd81bf40f79f1c509
                               at /rustc/3020239de947ec52677e9b4e853a6a9fc073d1f9/library/std/src/panicking.rs:286:9
  10:     0x7f34c7ca25a4 - rustc_driver[f75a378c450d3976]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f34c49686ed - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hce3fec4e8f82d2fd
                               at /rustc/3020239de947ec52677e9b4e853a6a9fc073d1f9/library/alloc/src/boxed.rs:2002:9
  12:     0x7f34c49686ed - std::panicking::rust_panic_with_hook::hed3ef434931562fa
                               at /rustc/3020239de947ec52677e9b4e853a6a9fc073d1f9/library/std/src/panicking.rs:692:13
  13:     0x7f34c4968469 - std::panicking::begin_panic_handler::{{closure}}::h1d8dbcf5f5b1c94f
                               at /rustc/3020239de947ec52677e9b4e853a6a9fc073d1f9/library/std/src/panicking.rs:579:13
  14:     0x7f34c49657cc - std::sys_common::backtrace::__rust_end_short_backtrace::hb1771d014f6a43ea
                               at /rustc/3020239de947ec52677e9b4e853a6a9fc073d1f9/library/std/src/sys_common/backtrace.rs:137:18
  15:     0x7f34c4968172 - rust_begin_unwind
                               at /rustc/3020239de947ec52677e9b4e853a6a9fc073d1f9/library/std/src/panicking.rs:575:5
  16:     0x7f34c49c4f23 - core::panicking::panic_fmt::hb8d8d3d1d1f13c08
                               at /rustc/3020239de947ec52677e9b4e853a6a9fc073d1f9/library/core/src/panicking.rs:64:14
  17:     0x7f34c49c5091 - core::panicking::panic_display::h56013a9eff8dcbba
                               at /rustc/3020239de947ec52677e9b4e853a6a9fc073d1f9/library/core/src/panicking.rs:147:5
  18:     0x7f34c49c503b - core::panicking::panic_str::h78d58cdfd82730fc
                               at /rustc/3020239de947ec52677e9b4e853a6a9fc073d1f9/library/core/src/panicking.rs:131:5
  19:     0x7f34c49c4ca6 - core::option::expect_failed::h3ccef436c6eb3748
                               at /rustc/3020239de947ec52677e9b4e853a6a9fc073d1f9/library/core/src/option.rs:1923:5
  20:     0x7f34c86f2b6e - <rustc_save_analysis[30a1dc8cb29e505f]::SaveContext>::get_expr_data
  21:     0x7f34c86d87d8 - <rustc_save_analysis[30a1dc8cb29e505f]::dump_visitor::DumpVisitor as rustc_hir[379d183c392bf9bf]::intravisit::Visitor>::visit_expr
  22:     0x7f34c86cde38 - <rustc_save_analysis[30a1dc8cb29e505f]::dump_visitor::DumpVisitor as rustc_hir[379d183c392bf9bf]::intravisit::Visitor>::visit_nested_body
  23:     0x7f34c86f5b6a - rustc_hir[379d183c392bf9bf]::intravisit::walk_generic_args::<rustc_save_analysis[30a1dc8cb29e505f]::dump_visitor::DumpVisitor>
  24:     0x7f34c86f7afd - rustc_hir[379d183c392bf9bf]::intravisit::walk_path::<rustc_save_analysis[30a1dc8cb29e505f]::dump_visitor::DumpVisitor>
  25:     0x7f34c86f5b6a - rustc_hir[379d183c392bf9bf]::intravisit::walk_generic_args::<rustc_save_analysis[30a1dc8cb29e505f]::dump_visitor::DumpVisitor>
  26:     0x7f34c86f7afd - rustc_hir[379d183c392bf9bf]::intravisit::walk_path::<rustc_save_analysis[30a1dc8cb29e505f]::dump_visitor::DumpVisitor>
  27:     0x7f34c86d34d3 - <rustc_save_analysis[30a1dc8cb29e505f]::dump_visitor::DumpVisitor as rustc_hir[379d183c392bf9bf]::intravisit::Visitor>::visit_item
  28:     0x7f34c86cde69 - <rustc_save_analysis[30a1dc8cb29e505f]::dump_visitor::DumpVisitor as rustc_hir[379d183c392bf9bf]::intravisit::Visitor>::visit_nested_item
  29:     0x7f34c86f6518 - rustc_hir[379d183c392bf9bf]::intravisit::walk_mod::<rustc_save_analysis[30a1dc8cb29e505f]::dump_visitor::DumpVisitor>
  30:     0x7f34c86d45c9 - <rustc_save_analysis[30a1dc8cb29e505f]::dump_visitor::DumpVisitor as rustc_hir[379d183c392bf9bf]::intravisit::Visitor>::visit_item
  31:     0x7f34c86cde69 - <rustc_save_analysis[30a1dc8cb29e505f]::dump_visitor::DumpVisitor as rustc_hir[379d183c392bf9bf]::intravisit::Visitor>::visit_nested_item
  32:     0x7f34c86f6518 - rustc_hir[379d183c392bf9bf]::intravisit::walk_mod::<rustc_save_analysis[30a1dc8cb29e505f]::dump_visitor::DumpVisitor>
  33:     0x7f34c86d45c9 - <rustc_save_analysis[30a1dc8cb29e505f]::dump_visitor::DumpVisitor as rustc_hir[379d183c392bf9bf]::intravisit::Visitor>::visit_item
  34:     0x7f34c86cde69 - <rustc_save_analysis[30a1dc8cb29e505f]::dump_visitor::DumpVisitor as rustc_hir[379d183c392bf9bf]::intravisit::Visitor>::visit_nested_item
  35:     0x7f34c86f6518 - rustc_hir[379d183c392bf9bf]::intravisit::walk_mod::<rustc_save_analysis[30a1dc8cb29e505f]::dump_visitor::DumpVisitor>
  36:     0x7f34c86d45c9 - <rustc_save_analysis[30a1dc8cb29e505f]::dump_visitor::DumpVisitor as rustc_hir[379d183c392bf9bf]::intravisit::Visitor>::visit_item
  37:     0x7f34c86cde69 - <rustc_save_analysis[30a1dc8cb29e505f]::dump_visitor::DumpVisitor as rustc_hir[379d183c392bf9bf]::intravisit::Visitor>::visit_nested_item
  38:     0x7f34c86f6518 - rustc_hir[379d183c392bf9bf]::intravisit::walk_mod::<rustc_save_analysis[30a1dc8cb29e505f]::dump_visitor::DumpVisitor>
  39:     0x7f34c86d1f4b - <rustc_save_analysis[30a1dc8cb29e505f]::dump_visitor::DumpVisitor>::process_crate
  40:     0x7f34c7c7c558 - <rustc_middle[d3830b30b3b6bcb0]::dep_graph::dep_node::DepKind as rustc_query_system[9558173104ffa4a8]::dep_graph::DepKind>::with_deps::<rustc_save_analysis[30a1dc8cb29e505f]::process_crate<rustc_save_analysis[30a1dc8cb29e505f]::DumpHandler>::{closure#0}, ()>
  41:     0x7f34c7c779ae - rustc_save_analysis[30a1dc8cb29e505f]::process_crate::<rustc_save_analysis[30a1dc8cb29e505f]::DumpHandler>
  42:     0x7f34c7c713c9 - <rustc_session[47a5956f246e9bfc]::session::Session>::time::<(), rustc_driver[f75a378c450d3976]::run_compiler::{closure#1}::{closure#2}::{closure#2}::{closure#0}>
  43:     0x7f34c6eb3a54 - <rustc_interface[faf3c08608b72f36]::passes::QueryContext>::enter::<rustc_driver[f75a378c450d3976]::run_compiler::{closure#1}::{closure#2}::{closure#2}, core[77a23254458137f7]::result::Result<(), rustc_errors[515aeced1161bc4]::ErrorGuaranteed>>
  44:     0x7f34c6eafdd3 - <rustc_interface[faf3c08608b72f36]::interface::Compiler>::enter::<rustc_driver[f75a378c450d3976]::run_compiler::{closure#1}::{closure#2}, core[77a23254458137f7]::result::Result<core[77a23254458137f7]::option::Option<rustc_interface[faf3c08608b72f36]::queries::Linker>, rustc_errors[515aeced1161bc4]::ErrorGuaranteed>>
  45:     0x7f34c6eaadb8 - rustc_span[2a613a2f02b6af2c]::with_source_map::<core[77a23254458137f7]::result::Result<(), rustc_errors[515aeced1161bc4]::ErrorGuaranteed>, rustc_interface[faf3c08608b72f36]::interface::run_compiler<core[77a23254458137f7]::result::Result<(), rustc_errors[515aeced1161bc4]::ErrorGuaranteed>, rustc_driver[f75a378c450d3976]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  46:     0x7f34c6eaa8a5 - <scoped_tls[cde101c268443f1a]::ScopedKey<rustc_span[2a613a2f02b6af2c]::SessionGlobals>>::set::<rustc_interface[faf3c08608b72f36]::interface::run_compiler<core[77a23254458137f7]::result::Result<(), rustc_errors[515aeced1161bc4]::ErrorGuaranteed>, rustc_driver[f75a378c450d3976]::run_compiler::{closure#1}>::{closure#0}, core[77a23254458137f7]::result::Result<(), rustc_errors[515aeced1161bc4]::ErrorGuaranteed>>
  47:     0x7f34c6ea9e92 - std[f433d76e435f6f2]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[faf3c08608b72f36]::util::run_in_thread_pool_with_globals<rustc_interface[faf3c08608b72f36]::interface::run_compiler<core[77a23254458137f7]::result::Result<(), rustc_errors[515aeced1161bc4]::ErrorGuaranteed>, rustc_driver[f75a378c450d3976]::run_compiler::{closure#1}>::{closure#0}, core[77a23254458137f7]::result::Result<(), rustc_errors[515aeced1161bc4]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[77a23254458137f7]::result::Result<(), rustc_errors[515aeced1161bc4]::ErrorGuaranteed>>
  48:     0x7f34c756d81a - <<std[f433d76e435f6f2]::thread::Builder>::spawn_unchecked_<rustc_interface[faf3c08608b72f36]::util::run_in_thread_pool_with_globals<rustc_interface[faf3c08608b72f36]::interface::run_compiler<core[77a23254458137f7]::result::Result<(), rustc_errors[515aeced1161bc4]::ErrorGuaranteed>, rustc_driver[f75a378c450d3976]::run_compiler::{closure#1}>::{closure#0}, core[77a23254458137f7]::result::Result<(), rustc_errors[515aeced1161bc4]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[77a23254458137f7]::result::Result<(), rustc_errors[515aeced1161bc4]::ErrorGuaranteed>>::{closure#1} as core[77a23254458137f7]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  49:     0x7f34c4972b23 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h8f2b7af54766d232
                               at /rustc/3020239de947ec52677e9b4e853a6a9fc073d1f9/library/alloc/src/boxed.rs:1988:9
  50:     0x7f34c4972b23 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hdc261654aadd28fc
                               at /rustc/3020239de947ec52677e9b4e853a6a9fc073d1f9/library/alloc/src/boxed.rs:1988:9
  51:     0x7f34c4972b23 - std::sys::unix::thread::Thread::new::thread_start::h2ffe427b25515558
                               at /rustc/3020239de947ec52677e9b4e853a6a9fc073d1f9/library/std/src/sys/unix/thread.rs:108:17
  52:     0x7f34c470cfd4 - start_thread
                               at ./nptl/./nptl/pthread_create.c:442:8
  53:     0x7f34c478d66c - __GI___clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
  54:                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/issues/new?labels=C-bug, I-ICE, T-compiler&template=ice.md

note: rustc 1.68.0-nightly (3020239de 2023-01-09) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED] -Z save-analysis

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

query stack during panic:
end of query stack
error: could not compile `icu_locid`
@sffc
Copy link
Member

sffc commented Jan 10, 2023

There's no line number in the ICU4X context. Can it be reduced to a certain file or line?

@makotokato
Copy link
Member Author

When dumping expr in rustc_save_analysis, it seems to be components/locid/src/extensions/transform/value.rs.

{
  hir_id: HirId(DefId(0:961 ~ icu_locid[9b55]::extensions::transform::value::Value).7),
  kind: MethodCall(PathSegment { 
    ident: end#0,
    hir_id: HirId(DefId(0:961 ~ icu_locid[9b55]::extensions::transform::value::Value).8),
   res: Err,
   args: None,
   infer_args: true
  },
  Expr {
    hir_id: HirId(DefId(0:961 ~ icu_locid[9b55]::extensions::transform::value::Value).9),
    kind: Path(Resolved(None, Path {
     span: components/locid/src/extensions/transform/value.rs:31:38: 31:49 (#0),
     res: Def(Const, DefId(0:347 ~ icu_locid[9b55]::extensions::transform::value::TYPE_LENGTH)),
     segments: [PathSegment { ident: TYPE_LENGTH#0, hir_id: HirId(DefId(0:961 ~ icu_locid[9b55]::extensions::transform::value::Value).10), res: Def(Const, DefId(0:347 ~ icu_locid[9b55]::extensions::transform::value::TYPE_LENGTH)), args: None, infer_args: true }]
     })),
    span: components/locid/src/extensions/transform/value.rs:31:38: 31:49 (#0) 
  }, [], components/locid/src/extensions/transform/value.rs:31:50: 31:55 (#0)), span: components/locid/src/extensions/transform/value.rs:31:38: 31:55 (#0)
}

@makotokato
Copy link
Member Author

makotokato commented Jan 10, 2023

pub struct Value(Vec<TinyAsciiStr<{ *TYPE_LENGTH.end() }>>); seems to cause this ICE. If we replace *TYPE_LENGTH.end() with static value, this doesn't occur. I re-create an issue as rust-lang/rust#106674 for rustc.

@sffc
Copy link
Member

sffc commented Jan 10, 2023

CC @robertbastian

@sffc
Copy link
Member

sffc commented Jan 19, 2023

  • @Manishearth - This is just save-analysis not supporting const generics. If we want to make our code build under save-analysis, it will restrict us to a smaller feature set. I think save-analysis is likely to go away if it's not already gone.

@makotokato Thoughts on this?

@sffc sffc added the needs-approval One or more stakeholders need to approve proposal label Jan 19, 2023
@Manishearth
Copy link
Member

For more background: save-analysis will probably gone in 2-3 releases. Searchfox should stop using it and look at alternatives, or disable Rust code xrefs.

There is some ongoing work for a replacement, but it's not there yet.

I guess in this particular case we can use the static value and add a fixme so that you're unblocked for now, but you really should talk to the searchfox team about this and let them know it's happening.

@sffc
Copy link
Member

sffc commented Feb 2, 2023

@makotokato @nordzilla Thoughts on this?

@makotokato
Copy link
Member Author

This is an optional. This faces when creating source code indexing, but this options will be removed by future version according to rust-lang/rust#101841

For searchfox, we will disable indexing on ICU4X code.

@Manishearth Manishearth closed this as not planned Won't fix, can't repro, duplicate, stale Feb 8, 2023
@sffc sffc added R-as-designed Resolution: By design principles, this won't be fixed and removed needs-approval One or more stakeholders need to approve proposal labels Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
R-as-designed Resolution: By design principles, this won't be fixed
Projects
None yet
Development

No branches or pull requests

3 participants