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

Rustc crashes with nul byte inside inline assembly #69092

Closed
andrewreds opened this issue Feb 12, 2020 · 2 comments · Fixed by #69966
Closed

Rustc crashes with nul byte inside inline assembly #69092

andrewreds opened this issue Feb 12, 2020 · 2 comments · Fixed by #69966
Assignees
Labels
A-inline-assembly Area: Inline assembly (`asm!(…)`) C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@andrewreds
Copy link

andrewreds commented Feb 12, 2020

Code

Fails

#![feature(asm)]

fn main() {
    unsafe { asm!(".ascii \"Xen\0\""); }
}

Works

#![feature(asm)]

fn main() {
    unsafe { asm!(".ascii \"Xen\\0\""); }
}
#![feature(asm)]

fn main() {
    unsafe { asm!(".asciz \"Xen\""); }
}

Meta

rustc --version --verbose:

rustc 1.43.0-nightly (fc23a8183 2020-02-11)
binary: rustc
commit-hash: fc23a81831d5b41510d3261c20c34dd8d32f0f31
commit-date: 2020-02-11
host: x86_64-unknown-linux-gnu
release: 1.43.0-nightly
LLVM version: 9.0

Error output

thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: NulError(11, [46, 97, 115, 99, 105, 105, 32, 34, 88, 101, 110, 0, 34])', src/librustc_codegen_llvm/asm.rs:77:19
note: run with `RUST_BACKTRACE=1` environment variable to display a 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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.43.0-nightly (fc23a8183 2020-02-11) running on x86_64-unknown-linux-gnu

Backtrace

stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:77
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1052
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1428
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:204
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:224
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:474
  12: rust_begin_unwind
             at src/libstd/panicking.rs:378
  13: core::panicking::panic_fmt
             at src/libcore/panicking.rs:85
  14: core::option::expect_none_failed
             at src/libcore/option.rs:1211
  15: rustc_codegen_llvm::asm::<impl rustc_codegen_ssa::traits::asm::AsmBuilderMethods for rustc_codegen_llvm::builder::Builder>::codegen_inline_asm
  16: rustc_codegen_ssa::mir::block::<impl rustc_codegen_ssa::mir::FunctionCx<Bx>>::codegen_block
  17: rustc_codegen_ssa::mir::codegen_mir
  18: <rustc::mir::mono::MonoItem as rustc_codegen_ssa::mono_item::MonoItemExt>::define
  19: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
  20: rustc::dep_graph::graph::DepGraph::with_task
  21: rustc_codegen_llvm::base::compile_codegen_unit
  22: rustc_codegen_ssa::base::codegen_crate
  23: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate
  24: rustc_interface::passes::QueryContext::enter
  25: rustc_interface::queries::Queries::ongoing_codegen
  26: rustc_interface::interface::run_compiler_in_existing_thread_pool
  27: scoped_tls::ScopedKey<T>::set
  28: syntax::attr::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

This issue has been assigned to @euclio via this comment.

@andrewreds andrewreds 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 Feb 12, 2020
@jonas-schievink jonas-schievink added A-inline-assembly Area: Inline assembly (`asm!(…)`) requires-nightly This issue requires a nightly compiler in some way. labels Feb 12, 2020
@euclio
Copy link
Contributor

euclio commented Feb 12, 2020

I'd like to work on this.

@rustbot claim

@rustbot rustbot self-assigned this Feb 12, 2020
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Feb 14, 2020
@JohnTitor
Copy link
Member

Now ICE no longer occurs, I think it's fixed by #69893. Marked as E-needstest.

@JohnTitor JohnTitor added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Mar 12, 2020
Centril added a commit to Centril/rust that referenced this issue Mar 13, 2020
@bors bors closed this as completed in 93da9d7 Mar 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-inline-assembly Area: Inline assembly (`asm!(…)`) C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. 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.

6 participants