rust-lang / rust

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

Panic while compiling sqlx with or without vendored openssl #115349

Open Grafcube opened 1 year ago

Grafcube commented 1 year ago

Code

https://codeberg.org/grafcube/wordforge/src/branch/flake-nix

The issue occured on my new device running NixOS. I cloned my repo and ran nix develop and then cargo leptos build. I tried using vendored dependencies according to launchbadge/sqlx#2244 but that didn't help. The branch linked above only differs from the main branch by the flake.nix file and the vendored dependencies for openssl. As far as I can tell, the error shouldn't also cause a compiler panic, so I opened this issue. I apologize for being unable to make a smaller example since I don't know exactly where the issue lies.

Meta

rustc --version --verbose:

rustc 1.74.0-nightly (4e78abb43 2023-08-28)
binary: rustc
commit-hash: 4e78abb437a0478d1f42115198ee45888e5330fd
commit-date: 2023-08-28
host: x86_64-unknown-linux-gnu
release: 1.74.0-nightly
LLVM version: 17.0.0

Error output

rustc-ice-2023-08-29T15:36:00.898907847Z-447547.txt

error: libssl.so.3: cannot open shared object file: No such file or directory
  --> /home/username/.local/share/cargo/registry/src/index.crates.io-6f17d22bba15001f/sqlx-0.6.3/src/lib.rs:67:1
   |
67 | pub extern crate sqlx_macros;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0432]: unresolved imports `self::encode::Encode`, `self::decode::Decode`, `super::Decode`, `super::Encode`, `super::FromRow`, `super::Type`
   --> /home/username/.local/share/cargo/registry/src/index.crates.io-6f17d22bba15001f/sqlx-0.6.3/src/lib.rs:126:9
    |
126 | pub use self::encode::Encode;
    |         ^^^^^^^^^^^^^^^^^^^^
...
137 | pub use self::decode::Decode;
    |         ^^^^^^^^^^^^^^^^^^^^
...
151 |     pub use super::Decode;
    |             ^^^^^^^^^^^^^
152 |     pub use super::Encode;
    |             ^^^^^^^^^^^^^
153 |     pub use super::Executor;
154 |     pub use super::FromRow;
    |             ^^^^^^^^^^^^^^
...
158 |     pub use super::Type;
    |             ^^^^^^^^^^^

thread 'rustc' panicked at compiler/rustc_resolve/src/lib.rs:1998:67:
internal error: entered unreachable code

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: please attach the file at `/home/username/.local/share/cargo/registry/src/index.crates.io-6f17d22bba15001f/sqlx-0.6.3/rustc-ice-2023-08-29T15:36:00.898907847Z-447547.txt` to your bug report

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

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

query stack during panic:
#0 [resolver_for_lowering] getting the resolver for lowering
end of query stack
For more information about this error, try `rustc --explain E0432`.
error: could not compile `sqlx` (lib) due to 2 previous errors
Error: Failed to build wordforge
Backtrace

``` stack backtrace: 0: rust_begin_unwind at /rustc/4e78abb437a0478d1f42115198ee45888e5330fd/library/std/src/panicking.rs:619:5 1: core::panicking::panic_fmt at /rustc/4e78abb437a0478d1f42115198ee45888e5330fd/library/core/src/panicking.rs:72:14 2: core::panicking::panic at /rustc/4e78abb437a0478d1f42115198ee45888e5330fd/library/core/src/panicking.rs:127:5 3: ::resolve_rustdoc_path 4: ::resolve_and_cache_rustdoc_path 5: ::resolve_doc_links 6: ::resolve_item 7: ::visit_item 8: ::late_resolve_crate 9: ::time::<(), ::resolve_crate::{closure#0}> 10: rustc_interface::passes::resolver_for_lowering [... omitted 2 frames ...] 11: ::enter::)>> 12: ::enter::, rustc_span::ErrorGuaranteed>> note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. ```

saethlin commented 1 year ago

I think I also ran into this recently but didn't get around to reporting it because I was already 2 compiler bugs deep in a morning.

kpreid commented 10 months ago

The provided reproducer code link is 404, so this issue has no repro at all right now. @rustbot label +S-needs-repro -E-needs-mcve

Be-ing commented 10 months ago

I'm running into this same ICE with Rust 1.75 stable compiling sqlx 0.7.3 as a dependency of atuin 17.2.1. Reproduce with

cargo install --locked atuin
   Compiling sqlx v0.7.3
   Compiling cipher v0.4.4
error: /tmp/cargo-installXD0NF6/release/deps/libsqlx_macros-a59ac22bb62984f9.so: undefined symbol: sqlite3_unlock_notify
  --> /home/be/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sqlx-0.7.3/src/lib.rs:53:1
   |
53 | pub extern crate sqlx_macros;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0432]: unresolved imports `self::encode::Encode`, `self::decode::Decode`, `super::Decode`, `super::Encode`, `super::FromRow`, `super::Type`
   --> /home/be/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sqlx-0.7.3/src/lib.rs:119:9
    |
119 | pub use self::encode::Encode;
    |         ^^^^^^^^^^^^^^^^^^^^
...
130 | pub use self::decode::Decode;
    |         ^^^^^^^^^^^^^^^^^^^^
...
144 |     pub use super::Decode;
    |             ^^^^^^^^^^^^^
145 |     pub use super::Encode;
    |             ^^^^^^^^^^^^^
146 |     pub use super::Executor;
147 |     pub use super::FromRow;
    |             ^^^^^^^^^^^^^^
...
151 |     pub use super::Type;
    |             ^^^^^^^^^^^

thread 'rustc' panicked at compiler/rustc_resolve/src/lib.rs:2006:67:
internal error: entered unreachable code
stack backtrace:
   0:     0x7f047f69f62c - std::backtrace_rs::backtrace::libunwind::trace::ha637c64ce894333a
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f047f69f62c - std::backtrace_rs::backtrace::trace_unsynchronized::h47f62dea28e0c88d
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f047f69f62c - std::sys_common::backtrace::_print_fmt::h9eef0abe20ede486
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f047f69f62c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hed7f999df88cc644
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f047f6f2630 - core::fmt::rt::Argument::fmt::h1539a9308b8d058d
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/fmt/rt.rs:142:9
   5:     0x7f047f6f2630 - core::fmt::write::h3a39390d8560d9c9
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f047f69354f - std::io::Write::write_fmt::h5fc9997dfe05f882
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/io/mod.rs:1762:15
   7:     0x7f047f69f414 - std::sys_common::backtrace::_print::h894006fb5c6f3d45
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f047f69f414 - std::sys_common::backtrace::print::h23a2d212c6fff936
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f047f6a20a7 - std::panicking::default_hook::{{closure}}::h8a1d2ee00185001a
  10:     0x7f047f6a1e0f - std::panicking::default_hook::h6038f2eba384e475
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:292:9
  11:     0x7f047c537190 - std[409886f6357001f0]::panicking::update_hook::<alloc[c1b021ad36e35877]::boxed::Box<rustc_driver_impl[7d23c5715ff089db]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f047f6a27e8 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h1f8f335eaa9cfaee
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/alloc/src/boxed.rs:2021:9
  13:     0x7f047f6a27e8 - std::panicking::rust_panic_with_hook::h2b5517d590cab22e
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:783:13
  14:     0x7f047f6a2509 - std::panicking::begin_panic_handler::{{closure}}::h233112c06e0ef43e
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:649:13
  15:     0x7f047f69faf6 - std::sys_common::backtrace::__rust_end_short_backtrace::h6e893f24d7ebbff8
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:170:18
  16:     0x7f047f6a22a2 - rust_begin_unwind
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:645:5
  17:     0x7f047f6eed15 - core::panicking::panic_fmt::hbf0e066aabfa482c
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:72:14
  18:     0x7f047f6eedb3 - core::panicking::panic::h195fc2a96298d4c3
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:127:5
  19:     0x7f047e02674c - <rustc_resolve[ec47402b5e317cbf]::late::LateResolutionVisitor>::resolve_and_cache_rustdoc_path
  20:     0x7f047e024ba3 - <rustc_resolve[ec47402b5e317cbf]::late::LateResolutionVisitor>::resolve_doc_links
  21:     0x7f047e3fd062 - <rustc_resolve[ec47402b5e317cbf]::late::LateResolutionVisitor as rustc_ast[b38fd0150461c9ea]::visit::Visitor>::visit_item
  22:     0x7f047e64ab24 - <rustc_resolve[ec47402b5e317cbf]::Resolver>::resolve_crate::{closure#0}
  23:     0x7f047e647e42 - <rustc_resolve[ec47402b5e317cbf]::Resolver>::resolve_crate
  24:     0x7f047e49c02b - rustc_interface[fbb0cb4be6c0ba34]::passes::resolver_for_lowering
  25:     0x7f047e49af89 - rustc_query_impl[664ae873a521fa7c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[664ae873a521fa7c]::query_impl::resolver_for_lowering::dynamic_query::{closure#2}::{closure#0}, rustc_middle[aca4860da4e5a967]::query::erase::Erased<[u8; 8usize]>>
  26:     0x7f047e5068e5 - rustc_query_system[b5dcdc06a735d5f1]::query::plumbing::try_execute_query::<rustc_query_impl[664ae873a521fa7c]::DynamicConfig<rustc_query_system[b5dcdc06a735d5f1]::query::caches::SingleCache<rustc_middle[aca4860da4e5a967]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[664ae873a521fa7c]::plumbing::QueryCtxt, false>
  27:     0x7f047e506fc9 - rustc_query_impl[664ae873a521fa7c]::query_impl::resolver_for_lowering::get_query_non_incr::__rust_end_short_backtrace
  28:     0x7f047e606e46 - rustc_interface[fbb0cb4be6c0ba34]::interface::run_compiler::<core[21cdcf8e8af4c2d9]::result::Result<(), rustc_span[3d5dc97049ad8d50]::ErrorGuaranteed>, rustc_driver_impl[7d23c5715ff089db]::run_compiler::{closure#1}>::{closure#0}
  29:     0x7f047e60215b - std[409886f6357001f0]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[fbb0cb4be6c0ba34]::util::run_in_thread_with_globals<rustc_interface[fbb0cb4be6c0ba34]::interface::run_compiler<core[21cdcf8e8af4c2d9]::result::Result<(), rustc_span[3d5dc97049ad8d50]::ErrorGuaranteed>, rustc_driver_impl[7d23c5715ff089db]::run_compiler::{closure#1}>::{closure#0}, core[21cdcf8e8af4c2d9]::result::Result<(), rustc_span[3d5dc97049ad8d50]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[21cdcf8e8af4c2d9]::result::Result<(), rustc_span[3d5dc97049ad8d50]::ErrorGuaranteed>>
  30:     0x7f047e601fb3 - <<std[409886f6357001f0]::thread::Builder>::spawn_unchecked_<rustc_interface[fbb0cb4be6c0ba34]::util::run_in_thread_with_globals<rustc_interface[fbb0cb4be6c0ba34]::interface::run_compiler<core[21cdcf8e8af4c2d9]::result::Result<(), rustc_span[3d5dc97049ad8d50]::ErrorGuaranteed>, rustc_driver_impl[7d23c5715ff089db]::run_compiler::{closure#1}>::{closure#0}, core[21cdcf8e8af4c2d9]::result::Result<(), rustc_span[3d5dc97049ad8d50]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[21cdcf8e8af4c2d9]::result::Result<(), rustc_span[3d5dc97049ad8d50]::ErrorGuaranteed>>::{closure#1} as core[21cdcf8e8af4c2d9]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  31:     0x7f047f6ac6a5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc7eafaff61e32df9
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/alloc/src/boxed.rs:2007:9
  32:     0x7f047f6ac6a5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h6ba4a5de48dd2304
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/alloc/src/boxed.rs:2007:9
  33:     0x7f047f6ac6a5 - std::sys::unix::thread::Thread::new::thread_start::he469335aef763e45
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys/unix/thread.rs:108:17
  34:     0x7f04798ac897 - start_thread
  35:     0x7f04799336fc - clone3
  36:                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.75.0 (82e1608df 2023-12-21) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type rlib -C opt-level=3 -C embed-bitcode=no -C link-arg=-fuse-ld=mold

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

query stack during panic:
#0 [resolver_for_lowering] getting the resolver for lowering
end of query stack
For more information about this error, try `rustc --explain E0432`.
error: could not compile `sqlx` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
error: failed to compile `atuin v17.2.1`, intermediate artifacts can be found at `/tmp/cargo-installXD0NF6`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.
saethlin commented 10 months ago

I ran

cargo +stable install --locked atuin --force

And did not get such a crash.

But the part of the error you've included tells me you've done some global cargo configuration, at the very least to add -Clink-arg=-fuse-ld=mold. What else have you configured?

Be-ing commented 10 months ago

Well this is interesting. I have

[build]
rustc-wrapper = "sccache"

in my ~/.cargo/config.toml to use sccache 0.7.4. When I comment that out, cargo install --locked atuin works. How is sccache able to trigger an ICE? :thinking: There may be a bug in sccache, but I doubt that should cause rustc to panic.

saethlin commented 10 months ago

Most likely you ran into a rustc bug at some other time which produced a broken build artifact, and now sccache is serving up that broken file.