Skip to content

ICE: compilation of clang-ast v0.1.13 failed the assertion #106787

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

Closed
VAmuzing opened this issue Jan 12, 2023 · 2 comments · Fixed by #115542
Closed

ICE: compilation of clang-ast v0.1.13 failed the assertion #106787

VAmuzing opened this issue Jan 12, 2023 · 2 comments · Fixed by #115542
Labels
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 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.

Comments

@VAmuzing
Copy link

Details:

The compiler failed the assertion when it was building the crate clang-ast v0.1.13
These are the compiler flags: --crate-type lib -C opt-level=3 -C embed-bitcode=no

Meta

rustc --version --verbose:

rustc 1.66.1 (90743e729 2023-01-10) (Rev1, Built by MSYS2 project)
binary: rustc
commit-hash: 90743e7298aca107ddaa0c202a4d3604e29bfeb6
commit-date: 2023-01-10
host: x86_64-pc-windows-gnu
release: 1.66.1
LLVM version: 15.0.5

Msys2.exe name: msys2-x86_64-20221216.exe

Error output

thread 'rustc' panicked at 'assertion failed: pos.get() <= self.position()', compiler\rustc_metadata\src\rmeta\encoder.rs:426:9
Backtrace

thread 'rustc' panicked at 'assertion failed: pos.get() <= self.position()', compiler\rustc_metadata\src\rmeta\encoder.rs:426:9
stack backtrace:
   0:     0x7ffe57f7d616 - std::backtrace_rs::backtrace::trace_unsynchronized::ha5de96ba347eafd0
   1:     0x7ffe57fb0cd2 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h86f0b2c8401c4d23
   2:     0x7ffe58021c2b - core::fmt::write::h64159b3979d9a8ee
   3:     0x7ffe57f8bd65 - std::io::Write::write_fmt::hf102e11bfde95957
   4:     0x7ffe57fb0a99 - std::sys_common::backtrace::print::h11028f9e8838163b
   5:     0x7ffe57f873bf - std::panicking::default_hook::{{closure}}::hdc2541b68d4c0642
   6:     0x7ffe57f87034 - std::panicking::default_hook::h1606c2fbb99540cf
   0:     0x7ffe57f7d616 - std::backtrace_rs::backtrace::trace_unsynchronized::ha5de96ba347eafd0
   1:     0x7ffe57fb0cd2 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h86f0b2c8401c4d23
   2:     0x7ffe58021c2b - core::fmt::write::h64159b3979d9a8ee
   3:     0x7ffe57f8bd65 - std::io::Write::write_fmt::hf102e11bfde95957
   4:     0x7ffe57fb0a99 - std::sys_common::backtrace::print::h11028f9e8838163b
   5:     0x7ffe57f873bf - std::panicking::default_hook::{{closure}}::hdc2541b68d4c0642
   6:     0x7ffe57f87034 - std::panicking::default_hook::h1606c2fbb99540cf
   7:     0x7ffe25b5b74c - rustc_driver[51b479947fb6b2c4]::DEFAULT_HOOK::{closure#0}::{closure#0}
   8:     0x7ffe57f87cd9 - std::panicking::rust_panic_with_hook::h42f16178e472c384
   9:     0x7ffe57fb13cf - std::panicking::begin_panic_handler::{{closure}}::he92c2af6cddd476a
  10:     0x7ffe57fb103f - std::sys_common::backtrace::__rust_end_short_backtrace::h68fc43e97b633613
  11:     0x7ffe57f87810 - rust_begin_unwind
  12:     0x7ffe5801f175 - core::panicking::panic_fmt::h538d8f294e3eef97
  13:     0x7ffe5801f25c - core::panicking::panic::h8329c37ec6c0781e
  14:     0x7ffe279e51a9 - <rustc_metadata[34f418474fb3aabd]::rmeta::encoder::EncodeContext>::encode_crate_root
  15:     0x7ffe279f7087 - rustc_metadata[34f418474fb3aabd]::rmeta::encoder::encode_metadata_impl
  16:     0x7ffe27af0e2d - rustc_data_structures[88bcd140e6e42ca9]::sync::join::<rustc_metadata[34f418474fb3aabd]::rmeta::encoder::encode_metadata::{closure#0}, rustc_metadata[34f418474fb3aa
bd]::rmeta::encoder::encode_metadata::{closure#1}, (), ()>
  17:     0x7ffe279f60fb - rustc_metadata[34f418474fb3aabd]::rmeta::encoder::encode_metadata
  18:     0x7ffe27a53d6e - rustc_metadata[34f418474fb3aabd]::fs::encode_and_write_metadata
  19:     0x7ffe25c46559 - <rustc_interface[b911231f48e138e8]::passes::QueryContext>::enter::<<rustc_interface[b911231f48e138e8]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}
, core[998ca2f06db80a1c]::result::Result<alloc[2e58b97199447900]::boxed::Box<dyn core[998ca2f06db80a1c]::any::Any>, rustc_errors[490555298d480402]::ErrorGuaranteed>>
  20:     0x7ffe25c08915 - <rustc_interface[b911231f48e138e8]::queries::Queries>::ongoing_codegen
  21:     0x7ffe25b2cb82 - rustc_span[5bbfdd86939e476c]::with_source_map::<core[998ca2f06db80a1c]::result::Result<(), rustc_errors[490555298d480402]::ErrorGuaranteed>, rustc_interface[b91123
1f48e138e8]::interface::run_compiler<core[998ca2f06db80a1c]::result::Result<(), rustc_errors[490555298d480402]::ErrorGuaranteed>, rustc_driver[51b479947fb6b2c4]::run_compiler::{closure#1}>::
{closure#0}::{closure#1}>
  22:     0x7ffe25b1b887 - <scoped_tls[12ed1ac40f3031d1]::ScopedKey<rustc_span[5bbfdd86939e476c]::SessionGlobals>>::set::<rustc_interface[b911231f48e138e8]::interface::run_compiler<core[998c
a2f06db80a1c]::result::Result<(), rustc_errors[490555298d480402]::ErrorGuaranteed>, rustc_driver[51b479947fb6b2c4]::run_compiler::{closure#1}>::{closure#0}, core[998ca2f06db80a1c]::result::R
esult<(), rustc_errors[490555298d480402]::ErrorGuaranteed>>
  23:     0x7ffe25ae0f27 - std[7460118f62c2f81c]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[b911231f48e138e8]::util::run_in_thread_pool_with_globals<rustc_interfa
ce[b911231f48e138e8]::interface::run_compiler<core[998ca2f06db80a1c]::result::Result<(), rustc_errors[490555298d480402]::ErrorGuaranteed>, rustc_driver[51b479947fb6b2c4]::run_compiler::{clos
ure#1}>::{closure#0}, core[998ca2f06db80a1c]::result::Result<(), rustc_errors[490555298d480402]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[998ca2f06db80a1c]::result::Result<(), rustc
_errors[490555298d480402]::ErrorGuaranteed>>
  24:     0x7ffe25ac324f - <<std[7460118f62c2f81c]::thread::Builder>::spawn_unchecked_<rustc_interface[b911231f48e138e8]::util::run_in_thread_pool_with_globals<rustc_interface[b911231f48e138
e8]::interface::run_compiler<core[998ca2f06db80a1c]::result::Result<(), rustc_errors[490555298d480402]::ErrorGuaranteed>, rustc_driver[51b479947fb6b2c4]::run_compiler::{closure#1}>::{closure
#0}, core[998ca2f06db80a1c]::result::Result<(), rustc_errors[490555298d480402]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[998ca2f06db80a1c]::result::Result<(), rustc_errors[490555298
d480402]::ErrorGuaranteed>>::{closure#1} as core[998ca2f06db80a1c]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  25:     0x7ffe57fba707 - std::sys::windows::thread::Thread::new::thread_start::h7b5a193639878ad8
  26:     0x7ffe92eb7614 - <unknown>
  27:     0x7ffe937c26a1 - <unknown>

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

@VAmuzing VAmuzing 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 12, 2023
@JohnTitor JohnTitor added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Jan 14, 2023
@langston-barrett
Copy link
Contributor

langston-barrett commented Mar 17, 2023

I couldn't reproduce this, here's what I tried:

git clone https://github.com/dtolnay/clang-ast
cd clang-ast
git checkout 0.1.13
cargo b --release --all-features
env RUSTFLAGS='-C opt-level=3 -C embed-bitcode=no' cargo b --release --all-features
rustc 1.68.0 (2c8cc3432 2023-03-06)
binary: rustc
commit-hash: 2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74
commit-date: 2023-03-06
host: x86_64-unknown-linux-gnu
release: 1.68.0
LLVM version: 15.0.6

@saethlin
Copy link
Member

saethlin commented Sep 4, 2023

Duplicate of #115298

@saethlin saethlin marked this as a duplicate of #115298 Sep 4, 2023
bors added a commit to rust-lang-ci/rust that referenced this issue Sep 11, 2023
…=<try>

Simplify/Optimize FileEncoder

FileEncoder is basically a BufWriter except that it exposes access to the not-written-to-yet region of the buffer so that some users can write directly to the buffer. This strategy is awesome because it lets us avoid calling memcpy for small copies, but the previous strategy was based on the writer accessing a `&mut [MaybeUninit<u8>; N]` and returning a `&[u8]` which is an API which currently mandates the use of unsafe code, making that interface in general not that appealing.

So this PR cleans up the FileEncoder implementation and builds on that general idea of direct buffer access in order to prevent `memcpy` calls in a few key places when encoding the dep graph and rmeta tables. The interface used here is now 100% safe, but with the caveat that internally we need to avoid trusting the number of bytes that the provided function claims to have written.

The original primary objective of this PR was to clean up the FileEncoder implementation so that the fix for the following issues would be easy to implement. The fix for these issues is to correctly update self.buffered even when writes fail, which I think it's easy to verify manually is now done, because all the FileEncoder methods are now small.

Fixes rust-lang#115298
Fixes rust-lang#114671
Fixes rust-lang#108100
Fixes rust-lang#106787
@bors bors closed this as completed in 3223b0b Sep 20, 2023
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Sep 21, 2023
…pkin

Simplify/Optimize FileEncoder

FileEncoder is basically a BufWriter except that it exposes access to the not-written-to-yet region of the buffer so that some users can write directly to the buffer. This strategy is awesome because it lets us avoid calling memcpy for small copies, but the previous strategy was based on the writer accessing a `&mut [MaybeUninit<u8>; N]` and returning a `&[u8]` which is an API which currently mandates the use of unsafe code, making that interface in general not that appealing.

So this PR cleans up the FileEncoder implementation and builds on that general idea of direct buffer access in order to prevent `memcpy` calls in a few key places when encoding the dep graph and rmeta tables. The interface used here is now 100% safe, but with the caveat that internally we need to avoid trusting the number of bytes that the provided function claims to have written.

The original primary objective of this PR was to clean up the FileEncoder implementation so that the fix for the following issues would be easy to implement. The fix for these issues is to correctly update self.buffered even when writes fail, which I think it's easy to verify manually is now done, because all the FileEncoder methods are small.

Fixes rust-lang/rust#115298
Fixes rust-lang/rust#114671
Fixes rust-lang/rust#114045
Fixes rust-lang/rust#108100
Fixes rust-lang/rust#106787
lnicola pushed a commit to lnicola/rust-analyzer that referenced this issue Apr 7, 2024
…pkin

Simplify/Optimize FileEncoder

FileEncoder is basically a BufWriter except that it exposes access to the not-written-to-yet region of the buffer so that some users can write directly to the buffer. This strategy is awesome because it lets us avoid calling memcpy for small copies, but the previous strategy was based on the writer accessing a `&mut [MaybeUninit<u8>; N]` and returning a `&[u8]` which is an API which currently mandates the use of unsafe code, making that interface in general not that appealing.

So this PR cleans up the FileEncoder implementation and builds on that general idea of direct buffer access in order to prevent `memcpy` calls in a few key places when encoding the dep graph and rmeta tables. The interface used here is now 100% safe, but with the caveat that internally we need to avoid trusting the number of bytes that the provided function claims to have written.

The original primary objective of this PR was to clean up the FileEncoder implementation so that the fix for the following issues would be easy to implement. The fix for these issues is to correctly update self.buffered even when writes fail, which I think it's easy to verify manually is now done, because all the FileEncoder methods are small.

Fixes rust-lang/rust#115298
Fixes rust-lang/rust#114671
Fixes rust-lang/rust#114045
Fixes rust-lang/rust#108100
Fixes rust-lang/rust#106787
RalfJung pushed a commit to RalfJung/rust-analyzer that referenced this issue Apr 27, 2024
…pkin

Simplify/Optimize FileEncoder

FileEncoder is basically a BufWriter except that it exposes access to the not-written-to-yet region of the buffer so that some users can write directly to the buffer. This strategy is awesome because it lets us avoid calling memcpy for small copies, but the previous strategy was based on the writer accessing a `&mut [MaybeUninit<u8>; N]` and returning a `&[u8]` which is an API which currently mandates the use of unsafe code, making that interface in general not that appealing.

So this PR cleans up the FileEncoder implementation and builds on that general idea of direct buffer access in order to prevent `memcpy` calls in a few key places when encoding the dep graph and rmeta tables. The interface used here is now 100% safe, but with the caveat that internally we need to avoid trusting the number of bytes that the provided function claims to have written.

The original primary objective of this PR was to clean up the FileEncoder implementation so that the fix for the following issues would be easy to implement. The fix for these issues is to correctly update self.buffered even when writes fail, which I think it's easy to verify manually is now done, because all the FileEncoder methods are small.

Fixes rust-lang/rust#115298
Fixes rust-lang/rust#114671
Fixes rust-lang/rust#114045
Fixes rust-lang/rust#108100
Fixes rust-lang/rust#106787
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants