Skip to content

ICE: no_core #98010

@Zymlex

Description

@Zymlex

Code

#![no_std]
#![no_core]
#![no_main]
#![feature(no_core, lang_items)]

#[lang = "sized"]
trait Sized {}
#[lang = "sync"]
trait Sync {}
#[lang = "copy"]
trait Copy {}
#[lang = "freeze"]
trait Freeze {}

impl Sync for u32 {}
impl Sync for i32 {}

// impl Copy for u32 {} // if remove, it cause rustc crash

#[lang = "drop_in_place"]
#[allow(unconditional_recursion)]
pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) { unsafe { drop_in_place(to_drop) } }

#[link(name = "Kernel32")]
extern "system" {
    pub fn ExitProcess(uexitcode: u32) -> !;
}

fn exit_process(exit_code: u32) -> ! { // Copying is necessary to pass the value through the function argument, and if this is avoided, there will be no error either.
    unsafe {
        ExitProcess(exit_code);
    }
}

#[no_mangle]
pub extern "C" fn wWinMainCRTStartup() -> i32 {
    exit_process(0);
}

#[no_mangle]
pub static _fltused: i32 = 1;

similar https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=7a195a8a96465739641bc5b737854d10

Cargo.toml:

[profile.release]
rustflags = [
    '-C', 'link-args=/NODEFAULTLIB /Zl /SUBSYSTEM:WINDOWS /SAFESEH:NO /DYNAMICBASE:NO /ENTRY:wWinMainCRTStartup /LTCG'
]
panic = "abort"

Meta

rustc --version --verbose:

rustc 1.63.0-nightly (ec55c6130 2022-06-10)
binary: rustc
commit-hash: ec55c61305eaf385fc1b93ac9a78284b4d887fe5
commit-date: 2022-06-10
host: x86_64-pc-windows-msvc
release: 1.63.0-nightly
LLVM version: 14.0.5

Error output

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: broken MIR in DefId(0:11 ~ test_no_core[9a43]::exit_process) (NoSolution): could not prove Binder(TraitPredicate(<u32 as Copy>, polarity:Positive), [])
  |
  = note: delayed at compiler\rustc_borrowck\src\type_check\canonical.rs:151:13

thread 'rustc' panicked at 'Box<dyn Any>', compiler\rustc_errors\src\lib.rs:1373:13
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.63.0-nightly (ec55c6130 2022-06-10) running on x86_64-pc-windows-msvc
note: compiler flags: --crate-type bin -C opt-level=3 -C link-args=/NODEFAULTLIB /Zl /SUBSYSTEM:WINDOWS /SAFESEH:NO /DYNAMICBASE:NO /ENTRY:wWinMainCRTStartup /LTCG -C panic=abort -C lto=fat -C codegen-units=1 -C incremental -Z macro-backtrace
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
end of query stack
error: could not compile `test`; 3 warnings emitted
Process finished with exit code 101

Backtrace

stack backtrace:
   0:     0x7ffcc6c09d1f - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h5878974d3101c2c1
   1:     0x7ffcc6c44d6a - core::fmt::write::h58b91005b62f62cb
   2:     0x7ffcc6bfc119 - <std::io::IoSlice as core::fmt::Debug>::fmt::h47ce2c587850b386
   3:     0x7ffcc6c0d60b - std::panicking::default_hook::h1cf6e1ccf8670b6e
   4:     0x7ffcc6c0d28b - std::panicking::default_hook::h1cf6e1ccf8670b6e
   5:     0x7ffcb68eb786 - rustc_driver[a11d5e36637d6ef8]::pretty::print_after_hir_lowering
   6:     0x7ffcc6c0ddb2 - std::panicking::rust_panic_with_hook::h8d89018be48b3be7
   7:     0x7ffcbb0b9ae5 - <rustc_errors[233cc4104dd9fe30]::styled_buffer::StyledChar as core[23edea91be4138c2]::fmt::Debug>::fmt
   8:     0x7ffcbb0b5969 - <rustc_errors[233cc4104dd9fe30]::styled_buffer::StyledChar as core[23edea91be4138c2]::fmt::Debug>::fmt
   9:     0x7ffcbb3fadf9 - rustc_query_system[4ba9814639d8c6d8]::query::plumbing::incremental_verify_ich_cold
  10:     0x7ffcbb0649a9 - <rustc_feature[80ac22f20521dda7]::builtin_attrs::AttributeType as core[23edea91be4138c2]::fmt::Debug>::fmt
  11:     0x7ffcbb0686dc - <rustc_errors[233cc4104dd9fe30]::HandlerInner as core[23edea91be4138c2]::ops::drop::Drop>::drop
  12:     0x7ffcb686cd64 - <rustc_lint[6c4a321fe5b8ec79]::BuiltinCombinedModuleLateLintPass as rustc_lint[6c4a321fe5b8ec79]::passes::LateLintPass>::check_mod_post
  13:     0x7ffcb68717ba - <rustc_lint[6c4a321fe5b8ec79]::BuiltinCombinedModuleLateLintPass as rustc_lint[6c4a321fe5b8ec79]::passes::LateLintPass>::check_mod_post
  14:     0x7ffcb68e40fd - <rustc_middle[fa74f14430eff12]::ty::SymbolName as core[23edea91be4138c2]::fmt::Debug>::fmt
  15:     0x7ffcb68e2319 - <rustc_middle[fa74f14430eff12]::ty::SymbolName as core[23edea91be4138c2]::fmt::Debug>::fmt
  16:     0x7ffcb687846d - <rustc_lint[6c4a321fe5b8ec79]::BuiltinCombinedModuleLateLintPass as rustc_lint[6c4a321fe5b8ec79]::passes::LateLintPass>::check_mod_post
  17:     0x7ffcb68dee76 - <rustc_metadata[7439ebc3b5fbc24c]::rmeta::encoder::EncodeContext as rustc_serialize[3bc617203079c8a5]::serialize::Encoder>::emit_raw_bytes
  18:     0x7ffcb68a2398 - <rustc_driver[a11d5e36637d6ef8]::args::Error as core[23edea91be4138c2]::fmt::Debug>::fmt
  19:     0x7ffcc6c1ef5c - std::sys::windows::thread::Thread::new::h40e1d95cdd0a661f
  20:     0x7ffcf5d47974 - BaseThreadInitThunk
  21:     0x7ffcf86ca2f1 - RtlUserThreadStart

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions