Page Fault in Rustc
Rustc version: redox-2025-01-12
after workaround of #1703
This rustc version has debug-logging = true
and crt-static = true
to show more error logs and eliminate possible bugs caused by dynamic linking.
A simple compilation with test.rs
in dev config with rustc will emits Page Fault. To be clear of what is causing that, we need to enable verbose logging:
env RUSTC_LOG=trace /usr/bin/rustc test.rs
It emits a very long logs, but the end of this log is:
DEBUG rustc_passes::stability annotate(id = DefId(0:2 ~ test[0374]::std), attrs = [Attribute { kind: Normal(AttrItem { unsafety: Safe, path: AttrPath { segments: [macro_use#1], span: no-location (#1) }, args: Empty }), id: AttrId(0), style: Outer, span: no-location (#1) }])
DEBUG rustc_passes::stability annotate(id = DefId(0:3 ~ test[0374]::main), attrs = [])
TRACE rustc_query_impl::query_impl::stability_index ret=Index { stab_map: UnordMap { inner: {} }, const_stab_map: UnordMap { inner: {} }, default_body_stab_map: UnordMap { inner: {} }, depr_map: UnordMap { inner: {} }, implications: UnordMap { inner: {} } }
TRACE rustc_query_impl::query_impl::stability_implications ret=UnordMap { inner: {} }
TRACE rustc_query_impl::query_impl::lib_features ret=LibFeatures { stability: UnordMap { inner: {} } }
TRACE rustc_query_impl::query_impl::limits ret=Limits { recursion_limit: Limit(128), move_size_limit: Limit(0), type_length_limit: Limit(16777216) }
rustc_hir_analysis::check::wfcheck::check_item item=Item { ident: #0, owner_id: DefId(0:1 ~ test[0374]::{use#0}), kind: Use(Path { span: no-location (#1), res: [Err], segments: [PathSegment { ident: {{root}}#1, hir_id: HirId(DefId(0:1 ~ test[0374]::{use#0}).1), res: Def(Mod, DefId(0:0 ~ test[0374])), args: None, infer_args: false }, PathSegment { ident: std#1, hir_id: HirId(DefId(0:1 ~ test[0374]::{use#0}).2), res: Def(Mod, DefId(1:0 ~ std[9e27])), args: None, infer_args: false }, PathSegment { ident: prelude#1, hir_id: HirId(DefId(0:1 ~ test[0374]::{use#0}).3), res: Def(Mod, DefId(1:46 ~ std[9e27]::prelude)), args: None, infer_args: false }, PathSegment { ident: rust_2015#1, hir_id: HirId(DefId(0:1 ~ test[0374]::{use#0}).4), res: Def(Mod, DefId(1:141 ~ std[9e27]::prelude::rust_2015)), args: None, infer_args: false }] }, Glob), span: no-location (#1), vis_span: no-location (#1) }
16ms DEBUG rustc_middle::ty::print::pretty def_path_str: def_id=DefId(0:1 ~ test[0374]::{use#0}), ns=TypeNS
Page fault: 0000000000000007 WR | US
RFLAG: 0000000000010202
CS: 000000000000002b
RIP: 0000000005f120bd
RSP: 000000000832ce20
SS: 0000000000000023
FSBASE 00000000002db000
GSBASE 0000000000000000
KGSBASE ffff800001768000
RAX: 000000000dd7cf20
RCX: 0000000000000007
RDX: 00000000000be9e0
RDI: 00000000000000ff
RSI: 0000000000000000
R8: 0000000000000006
R9: 0000000000000000
R10: 0000000000000008
R11: 0000000000000000
RBX: 000000000832cf60
RBP: 000000000832ce60
R12: 000000000832d020
R13: 000000000e594500
R14: 000000000832ce78
R15: 0000000000000001
FP ffff80003069fe20: PC ffffffff8008f9fb
FFFFFFFF8008F7F0+020B
kernel::arch::x86_64::interrupt::exception::page::inner
FP ffff80003069ff50: PC ffffffff80083117
FFFFFFFF800830E0+0037
kernel::arch::x86_64::interrupt::exception::page
000000000832ce60: GUARD PAGE
kernel::context::signal:INFO -- UNHANDLED EXCEPTION, CPU #0, PID 86, NAME /usr/bin/rustc, CONTEXT 0xffffff7f80039a50
I'm clueless of what causes page fault. I'll be comparing with how the stage1 compiler compiles the same thing
RUSTC_LOG=trace /mnt/redox/cookbook/recipes/dev/rust/target/x86_64-unknown-redox/build/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnu/release/rustc-main --sysroot /mnt/redox/cookbook/recipes/dev/rust/target/x86_64-unknown-redox/build/build/x86_64-unknown-linux-gnu/stage1 test.rs &> log
rustc_hir_analysis::check::wfcheck::check_item item=Item { ident: #0, owner_id: DefId(0:1 ~ test[0374]::{use#0}), kind: Use(Path { span: no-location (#1), res: [Err], segments: [PathSegment { ident: {{root}}#1, hir_id: HirId(DefId(0:1 ~ test[0374]::{use#0}).1), res: Def(Mod, DefId(0:0 ~ test[0374])), args: None, infer_args: false }, PathSegment { ident: std#1, hir_id: HirId(DefId(0:1 ~ test[0374]::{use#0}).2), res: Def(Mod, DefId(1:0 ~ std[4769])), args: None, infer_args: false }, PathSegment { ident: prelude#1, hir_id: HirId(DefId(0:1 ~ test[0374]::{use#0}).3), res: Def(Mod, DefId(1:46 ~ std[4769]::prelude)), args: None, infer_args: false }, PathSegment { ident: rust_2015#1, hir_id: HirId(DefId(0:1 ~ test[0374]::{use#0}).4), res: Def(Mod, DefId(1:141 ~ std[4769]::prelude::rust_2015)), args: None, infer_args: false }] }, Glob), span: no-location (#1), vis_span: no-location (#1) }
0ms DEBUG rustc_middle::ty::print::pretty def_path_str: def_id=DefId(0:1 ~ test[0374]::{use#0}), ns=TypeNS
1ms TRACE rustc_query_impl::query_impl::extern_crate ret=Some(ExternCrate { src: Extern(DefId(0:2 ~ test[0374]::std)), span: no-location (#1), path_len: 1, dependency_of: crate0 })
1ms TRACE rustc_query_impl::query_impl::extern_crate ret=Some(ExternCrate { src: Extern(DefId(0:2 ~ test[0374]::std)), span: no-location (#1), path_len: 1, dependency_of: crate1 })
1ms TRACE rustc_query_impl::query_impl::extern_crate ret=Some(ExternCrate { src: Extern(DefId(0:2 ~ test[0374]::std)), span: no-location (#1), path_len: 1, dependency_of: crate1 })
1ms TRACE rustc_query_impl::query_impl::extern_crate ret=Some(ExternCrate { src: Extern(DefId(0:2 ~ test[0374]::std)), span: no-location (#1), path_len: 1, dependency_of: crate3 })
1ms TRACE rustc_query_impl::query_impl::extern_crate ret=Some(ExternCrate { src: Extern(DefId(0:2 ~ test[0374]::std)), span: no-location (#1), path_len: 1, dependency_of: crate1 })
1ms TRACE rustc_query_impl::query_impl::extern_crate ret=Some(ExternCrate { src: Extern(DefId(0:2 ~ test[0374]::std)), span: no-location (#1), path_len: 1, dependency_of: crate1 })
1ms TRACE rustc_query_impl::query_impl::extern_crate ret=Some(ExternCrate { src: Extern(DefId(0:2 ~ test[0374]::std)), span: no-location (#1), path_len: 1, dependency_of: crate1 })
1ms TRACE rustc_query_impl::query_impl::extern_crate ret=Some(ExternCrate { src: Extern(DefId(0:2 ~ test[0374]::std)), span: no-location (#1), path_len: 1, dependency_of: crate7 })
1ms TRACE rustc_query_impl::query_impl::extern_crate ret=Some(ExternCrate { src: Extern(DefId(0:2 ~ test[0374]::std)), span: no-location (#1), path_len: 1, dependency_of: crate1 })
1ms TRACE rustc_query_impl::query_impl::extern_crate ret=Some(ExternCrate { src: Extern(DefId(0:2 ~ test[0374]::std)), span: no-location (#1), path_len: 1, dependency_of: crate9 })
1ms TRACE rustc_query_impl::query_impl::extern_crate ret=Some(ExternCrate { src: Extern(DefId(0:2 ~ test[0374]::std)), span: no-location (#1), path_len: 1, dependency_of: crate1 })
1ms TRACE rustc_query_impl::query_impl::extern_crate ret=Some(ExternCrate { src: Extern(DefId(0:2 ~ test[0374]::std)), span: no-location (#1), path_len: 1, dependency_of: crate11 })
1ms TRACE rustc_query_impl::query_impl::extern_crate ret=Some(ExternCrate { src: Extern(DefId(0:2 ~ test[0374]::std)), span: no-location (#1), path_len: 1, dependency_of: crate1 })
1ms TRACE rustc_query_impl::query_impl::extern_crate ret=Some(ExternCrate { src: Extern(DefId(0:2 ~ test[0374]::std)), span: no-location (#1), path_len: 1, dependency_of: crate1 })
1ms TRACE rustc_query_impl::query_impl::extern_crate ret=Some(ExternCrate { src: Extern(DefId(0:2 ~ test[0374]::std)), span: no-location (#1), path_len: 1, dependency_of: crate1 })
1ms TRACE rustc_query_impl::query_impl::extern_crate ret=Some(ExternCrate { src: Extern(DefId(0:2 ~ test[0374]::std)), span: no-location (#1), path_len: 1, dependency_of: crate15 })
1ms TRACE rustc_query_impl::query_impl::extern_crate ret=Some(ExternCrate { src: Extern(DefId(0:2 ~ test[0374]::std)), span: no-location (#1), path_len: 1, dependency_of: crate1 })
1ms TRACE rustc_query_impl::query_impl::extern_crate ret=Some(ExternCrate { src: Extern(DefId(0:2 ~ test[0374]::std)), span: no-location (#1), path_len: 1, dependency_of: crate17 })
1ms TRACE rustc_query_impl::query_impl::extern_crate ret=Some(ExternCrate { src: Extern(DefId(0:2 ~ test[0374]::std)), span: no-location (#1), path_len: 1, dependency_of: crate1 })
2ms TRACE rustc_query_impl::query_impl::module_children ret=[ModChild { ident: assert_matches#0, res: Def(Macro(Bang), DefId(2:7 ~ core[288f]::macros::assert_matches)), vis: Public, reexport_chain: [Single(DefId(2:57 ~ core[288f]::assert_matches::{use#1}))] }, ModChild { ident: debug_assert_matches#0, res: Def(Macro(Bang), DefId(2:12 ~ core[288f]::macros::debug_assert_matches)), vis: Public, reexport_chain: [Single(DefId(2:58 ~ core[288f]::assert_matches::{use#2}))] }]
4ms DEBUG rustc_metadata::rmeta::decoder try_to_translate_virtual_to_real(name=Real(LocalPath("/mnt/redox/cookbook/recipes/dev/rust/source/library/core/src/primitive.rs"))): virtual_rust_source_base_dir=[None, None], real_rust_source_base_dir=Some("/mnt/redox/cookbook/recipes/dev/rust/source")
4ms DEBUG rustc_metadata::rmeta::decoder CrateMetaData::imported_source_files alloc source_file Real(LocalPath("/mnt/redox/cookbook/recipes/dev/rust/source/library/core/src/primitive.rs")) original (start_pos BytePos(0) source_len RelativeBytePos(2403)) translated (start_pos BytePos(1387242) source_len RelativeBytePos(2403))
4ms TRACE rustc_query_impl::query_impl::module_children ret=[ModChild { ident: bool#0, res: PrimTy(Bool), vis: Public, reexport_chain: [Single(DefId(2:15236 ~ core[288f]::primitive::{use#0}))] }, ModChild { ident: char#0, res: PrimTy(Char), vis: Public, reexport_chain: [Single(DefId(2:15237 ~ core[288f]::primitive::{use#1}))] }, ModChild { ident: f32#0, res: PrimTy(Float(F32)), vis: Public, reexport_chain: [Single(DefId(2:15238 ~ core[288f]::primitive::{use#2}))] }, ModChild { ident: f64#0, res: PrimTy(Float(F64)), vis: Public, reexport_chain: [Single(DefId(2:15239 ~ core[288f]::primitive::{use#3}))] }, ModChild { ident: i8#0, res: PrimTy(Int(I8)), vis: Public, reexport_chain: [Single(DefId(2:15240 ~ core[288f]::primitive::{use#4}))] }, ModChild { ident: i16#0, res: PrimTy(Int(I16)), vis: Public, reexport_chain: [Single(DefId(2:15241 ~ core[288f]::primitive::{use#5}))] }, ModChild { ident: i32#0, res: PrimTy(Int(I32)), vis: Public, reexport_chain: [Single(DefId(2:15242 ~ core[288f]::primitive::{use#6}))] }, ModChild { ident: i64#0, res: PrimTy(Int(I64)), vis: Public, reexport_chain: [Single(DefId(2:15243 ~ core[288f]::primitive::{use#7}))] }, ModChild { ident: i128#0, res: PrimTy(Int(I128)), vis: Public, reexport_chain: [Single(DefId(2:15244 ~ core[288f]::primitive::{use#8}))] }, ModChild { ident: isize#0, res: PrimTy(Int(Isize)), vis: Public, reexport_chain: [Single(DefId(2:15245 ~ core[288f]::primitive::{use#9}))] }, ModChild { ident: str#0, res: PrimTy(Str), vis: Public, reexport_chain: [Single(DefId(2:15246 ~ core[288f]::primitive::{use#10}))] }, ModChild { ident: u8#0, res: PrimTy(Uint(U8)), vis: Public, reexport_chain: [Single(DefId(2:15247 ~ core[288f]::primitive::{use#11}))] }, ModChild { ident: u16#0, res: PrimTy(Uint(U16)), vis: Public, reexport_chain: [Single(DefId(2:15248 ~ core[288f]::primitive::{use#12}))] }, ModChild { ident: u32#0, res: PrimTy(Uint(U32)), vis: Public, reexport_chain: [Single(DefId(2:15249 ~ core[288f]::primitive::{use#13}))] }, ModChild { ident: u64#0, res: PrimTy(Uint(U64)), vis: Public, reexport_chain: [Single(DefId(2:15250 ~ core[288f]::primitive::{use#14}))] }, ModChild { ident: u128#0, res: PrimTy(Uint(U128)), vis: Public, reexport_chain: [Single(DefId(2:15251 ~ core[288f]::primitive::{use#15}))] }, ModChild { ident: usize#0, res: PrimTy(Uint(Usize)), vis: Public, reexport_chain: [Single(DefId(2:15252 ~ core[288f]::primitive::{use#16}))] }]
4ms DEBUG rustc_metadata::rmeta::decoder try_to_translate_virtual_to_real(name=Real(LocalPath("/mnt/redox/cookbook/recipes/dev/rust/source/library/alloc/src/vec/mod.rs"))): virtual_rust_source_base_dir=[None, None], real_rust_source_base_dir=Some("/mnt/redox/cookbook/recipes/dev/rust/source")
From the error logs diff, it's suggested that rustc_query_impl::query_impl::extern_crate
does something that the kernel is not expecting to happen. The code that triggers this is gated around proc macro which I don't understand.
I'm attaching full log for stage1-linux-log and redox-os-log