Repository navigation
ICE: assertion failed: bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32 #110885
Copy link
Copy link
Closed
Closed
Copy link
Labels
A-inline-assemblyArea: Inline assembly (`asm!(…)`)Area: Inline assembly (`asm!(…)`)C-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Hi I got two confusions when trying to use global_asm and integrate some assembly codes.
- I got the internal compiler error listed as below;
- The error messages look wierd with arrows confusingly pointing to blankets or some existing labels. (If I just misunderstood them please correct me)
Any Help would be appreciated very much :D
Code
use core::arch::global_asm;
global_asm!(include_str!("./arm/func.S"), options(raw));
global_asm!(include_str!("./bug/bug.s"), options(raw));
fn main() {
}func.S:
#include "macro_a.S"
#include "macro_b.S"
#include "macro_c.S"
.text
.arch armv8-a+crypto
.globl SOME_FUNC_A
.type SOME_FUNC_A,%function
.align 4
SOME_FUNC_A:
IN_STP // 寄存器保护
b.eq .LEnc_1_process // 跳转
b.eq .LEnc_2_process // 跳转
b .LEnc_3_process // 跳转
.LEnc_1_process:
LOAD_HASH_TABLE // 加载g
b.le .LEnc_end // 第一次64字节处理完毕,判断剩余长度
b .LEnc_1_loop // 进入循环处理流程
.LEnc_2_process:
LOAD_HASH_TABLE // load hash table
b.le .LEnc_end
b .LEnc_2_loop
.LEnc_3_process:
LOAD_HASH_TABLE
b.le .LEnc_end
b .LEnc_3_loop
.LEnc_1_loop:
ENC1_LOOP // 处理64字节
b.le .LEnc_end // 剩余块数为0, 退出循环
b .LEnc_1_loop // 继续循环
.LEnc_2_loop:
ENC2_LOOP
b.le .LEnc_end // <= 0
b .LEnc_2_loop
.LEnc_3_loop:
ENC3_LOOP
b.le .LEnc_end // <= 0
b .LEnc_3_loop
.LEnc_end:
HASH_BLOCK
OUT_STP
.LEnc_ret:
ret
.size SOME_FUNC_A,.-SOME_FUNC_A
bug.s:
#include "macro_a.S"
#include "macro_b.S"
#include "macro_c.S"
.globl SOME_FUNC_A
.type SOME_FUNC_A,%function
.align 4
SOME_FUNC_A:
IN_STP // 寄存器保护
b.eq .LEnc_1_process // 跳转1处理逻辑
b.eq .LEnc_2_process // 跳转2处理逻辑
b .LEnc_3_process // 跳转3处理逻辑
.LEnc_1_process:
b .LEnc_1_loop // 进入循环处理流程
.LEnc_1_loop:
b .LEnc_1_loop // 继续循环
.size SOME_FUNC_A,.-SOME_FUNC_A
Meta
rustc --version --verbose:
<version>
rustc 1.67.0 (fc594f156 2023-01-24)
binary: rustc
commit-hash: fc594f15669680fa70d255faec3ca3fb507c3405
commit-date: 2023-01-24
host: aarch64-unknown-linux-gnu
release: 1.67.0
LLVM version: 15.0.6
Error output
<output>
Backtrace
<backtrace>
Compiling main v0.1.0 (/usr1/w00620137/rust_dev/test/main)
error: unrecognized instruction mnemonic
|
note: instantiated into assembly here
--> <inline asm>:12:16
|
12 | IN_STP // 寄存器保护
| ^
error: unrecognized instruction mnemonic
|
note: instantiated into assembly here
--> <inline asm>:18:22
|
18 | LOAD_HASH_TABLE // 加载g
| ^
error: unrecognized instruction mnemonic
|
note: instantiated into assembly here
--> <inline asm>:23:27
|
23 | LOAD_HASH_TABLE // load hash table
| ^
error: unrecognized instruction mnemonic
|
note: instantiated into assembly here
--> <inline asm>:29:12
|
29 | b.le .LEnc_end
| ^
error: unrecognized instruction mnemonic
|
note: instantiated into assembly here
--> <inline asm>:33:37
|
33 | ENC1_LOOP // 处理64字节
| ^
error: unrecognized instruction mnemonic
|
note: instantiated into assembly here
--> <inline asm>:39:28
|
39 | b.le .LEnc_end // <= 0
| ^
error: unrecognized instruction mnemonic
|
note: instantiated into assembly here
--> <inline asm>:44:33
|
44 | b.le .LEnc_end // <= 0
| ^
error: unrecognized instruction mnemonic
|
note: instantiated into assembly here
--> <inline asm>:53:5
|
53 | .size SOME_FUNC_A,.-SOME_FUNC_A
| ^
error: unrecognized instruction mnemonic
|
note: instantiated into assembly here
--> <inline asm>:53:21
|
53 | .size SOME_FUNC_A,.-SOME_FUNC_A
| ^
error: symbol 'SOME_FUNC_A' is already defined
|
note: instantiated into assembly here
--> <inline asm>:62:48
|
62 | IN_STP // 寄存器保护
| ^
thread 'rustc' panicked at 'assertion failed: bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32', compiler/rustc_span/src/lib.rs:1698:17
stack backtrace:
0: rust_begin_unwind
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:575:5
1: core::panicking::panic_fmt
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/panicking.rs:64:14
2: core::panicking::panic
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/panicking.rs:111:5
3: <rustc_span::SourceFile>::lookup_file_pos
4: <rustc_span::SourceFile>::lookup_file_pos_with_col_display
5: <rustc_span::source_map::SourceMap>::lookup_char_pos
6: <rustc_errors::emitter::EmitterWriter>::get_multispan_max_line_num
7: <rustc_errors::emitter::EmitterWriter>::emit_messages_default
8: <rustc_errors::emitter::EmitterWriter as rustc_errors::emitter::Emitter>::emit_diagnostic
9: <rustc_errors::json::Diagnostic>::from_errors_diagnostic
10: <rustc_errors::json::JsonEmitter as rustc_errors::emitter::Emitter>::emit_diagnostic
11: <rustc_errors::HandlerInner>::emit_diagnostic
12: <() as rustc_errors::diagnostic_builder::EmissionGuarantee>::diagnostic_builder_emit_producing_guarantee
13: <rustc_codegen_ssa::back::write::SharedEmitterMain>::check
14: <rustc_codegen_ssa::back::write::OngoingCodegen<rustc_codegen_llvm::LlvmCodegenBackend>>::join
15: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::join_codegen
16: <rustc_interface::queries::Linker>::link
17: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
18: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
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%2C+I-ICE%2C+T-compiler&template=ice.md
note: rustc 1.67.0 (fc594f156 2023-01-24) running on aarch64-unknown-linux-gnu
note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
end of query stack
error: could not compile `main` due to 10 previous errors
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-inline-assemblyArea: Inline assembly (`asm!(…)`)Area: Inline assembly (`asm!(…)`)C-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Activity
Amanieu commentedon Apr 27, 2023
You can't use
#includewith assembly code used byglobal_asm!. This requires running a C pre-processor over the assembly code which can only be done withbuild.rs.However the assertion failure is still a real issue in the compiler.
WendyWjt commentedon Apr 27, 2023
(https://modexp.wordpress.com/2018/10/30/arm64-assembly/#comments)
Is it not allowed to use as comments?
Amanieu commentedon Apr 27, 2023
It won't include
macro_a.s, which is what the originally assembly code intended to do. It will instead just be parsed as a comment and ignored.WendyWjt commentedon Apr 27, 2023
Ohh ok I get it. Thank you for your explanations :D
Amanieu commentedon Apr 27, 2023
I can't reproduce the assertion failure in the latest rustc:
WendyWjt commentedon Apr 28, 2023
Maybe try this one? main.zip
I try to update the rustc version, but the error still exists. I use
fileandxxdto check the assembly files that can and can't reproduce the ICE, and find some differences: their encodings differ with terminators, one with\r\n(with ICE) and another with only\r(without ICE). Also, error information aboutunrecognized instruction mnemoniccompiling with assembly files with\r\ndisplays arrows confusingly pointing to blankets, but for files with only\r, error info is the same as yours'. Arrows point to the beginning of the tags or instructions, which makes sense in a way.I don't know whether the terminator is the root cause. Hope that could help figure it out.
The new meta info I get after updating the rustc version:
Meta
rustc --version --verbose:Error output
Backtrace
The files that can cause the compiler error:
file *xxd func.Sfile *xxd bug.sThe files that won't cause the compiler error:
file *xxd func.Sfile *xxd bug.sRollup merge of rust-lang#110985 - Amanieu:normalize_asm_spans, r=b-n…
Rollup merge of rust-lang#151455 - eggyal:normalized-byte-pos, r=cjgi…
Rollup merge of rust-lang#151455 - eggyal:normalized-byte-pos, r=cjgi…
Rollup merge of rust-lang#151455 - eggyal:normalized-byte-pos, r=cjgi…
Rollup merge of rust-lang#151455 - eggyal:normalized-byte-pos, r=cjgi…
Auto merge of #151455 - eggyal:normalized-byte-pos, r=cjgillot
Rollup merge of rust-lang#151455 - eggyal:normalized-byte-pos, r=cjgi…
Unrolled build for #151455