tomaka/redshirt

Linked list allocator panics in debug

Closed this issue · 1 comments

This might be the underlying cause for #209, although that is pure suspicion.

Panic message:

attempt to copy from unaligned or null pointer

Backtrace:

#0  x86_64::instructions::hlt () at /home/pierre/.cargo/registry/src/github.com-1ecc6299db9ec823/x86_64-0.8.2/src/instructions/mod.rs:18
#1  0x0000000000401365 in redshirt_standalone_kernel::arch::x86_64::halt () at kernel/standalone/src/arch/x86_64.rs:58
#2  0x0000000000426e57 in rust_begin_unwind (panic_info=<optimized out>) at kernel/standalone/src/panic.rs:51
#3  0x00000000004fdede in core::panicking::panic_fmt (fmt=..., location=<optimized out>) at /home/pierre/.rustup/toolchains/nightly-2019-12-05-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/panicking.rs:82
#4  0x00000000004fde3e in core::panicking::panic (expr=..., location=0xa) at /home/pierre/.rustup/toolchains/nightly-2019-12-05-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/panicking.rs:49
#5  0x000000000042bfe5 in core::intrinsics::copy_nonoverlapping (src=0x2227ee9, dst=0x13a83e0 <stack+8344544>, count=1)
    at /home/pierre/.rustup/toolchains/nightly-2019-12-05-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/macros/mod.rs:15
#6  0x000000000042c099 in core::ptr::read (src=0x0) at /home/pierre/.rustup/toolchains/nightly-2019-12-05-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/ptr/mod.rs:616
#7  0x000000000042c050 in core::ptr::swap_nonoverlapping_one (x=0x2227ee9, y=0x13a8410 <stack+8344592>) at /home/pierre/.rustup/toolchains/nightly-2019-12-05-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/ptr/mod.rs:403
#8  0x000000000042c021 in core::mem::replace (dest=0x0, src=...) at /home/pierre/.rustup/toolchains/nightly-2019-12-05-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/mem/mod.rs:681
#9  0x000000000042c660 in linked_list_allocator::hole::allocate_first_fit (previous=0xbb0838 <redshirt_standalone_kernel::mem_alloc::ALLOCATOR+24>, layout=...)
    at /home/pierre/.cargo/registry/src/github.com-1ecc6299db9ec823/linked_list_allocator-0.6.4/src/hole.rs:201
#10 0x000000000042c2e8 in linked_list_allocator::hole::HoleList::allocate_first_fit (self=0xbb0838 <redshirt_standalone_kernel::mem_alloc::ALLOCATOR+24>, layout=...)
    at /home/pierre/.cargo/registry/src/github.com-1ecc6299db9ec823/linked_list_allocator-0.6.4/src/hole.rs:52
#11 0x000000000042be16 in <linked_list_allocator::LockedHeap as core::alloc::GlobalAlloc>::alloc (self=<optimized out>, layout=...)
    at /home/pierre/.cargo/registry/src/github.com-1ecc6299db9ec823/linked_list_allocator-0.6.4/src/lib.rs:177
#12 0x00000000004fa576 in <alloc::alloc::Global as core::alloc::Alloc>::alloc (self=<optimized out>, layout=...)
    at /home/pierre/.rustup/toolchains/nightly-2019-12-05-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/liballoc/alloc.rs:172
#13 0x00000000004fab0d in alloc::raw_vec::RawVec<T,A>::reserve_internal (self=0x13a86f0 <stack+8345328>, used_capacity=<optimized out>, needed_extra_capacity=<optimized out>, fallibility=alloc::raw_vec::Fallibility::Infallible, 
    strategy=<optimized out>) at /home/pierre/.rustup/toolchains/nightly-2019-12-05-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/liballoc/raw_vec.rs:695
#14 0x00000000004fa811 in alloc::raw_vec::RawVec<T,A>::reserve (self=0xa, used_capacity=10, needed_extra_capacity=0)
    at /home/pierre/.rustup/toolchains/nightly-2019-12-05-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/liballoc/raw_vec.rs:520
#15 0x00000000004f959d in <alloc::vec::Vec<T> as alloc::vec::SpecExtend<&T,core::slice::Iter<T>>>::spec_extend (self=0x13a86f0 <stack+8345328>, iterator=...)
    at /home/pierre/.rustup/toolchains/nightly-2019-12-05-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/liballoc/vec.rs:2081
#16 0x0000000000454208 in parity_wasm::elements::section::SectionReader::new (reader=0x13acc00 <stack+8363008>) at /home/pierre/.cargo/registry/src/github.com-1ecc6299db9ec823/parity-wasm-0.41.0/src/elements/mod.rs:17
#17 0x0000000000453f1a in parity_wasm::elements::section::read_entries (reader=0xa) at /home/pierre/.cargo/registry/src/github.com-1ecc6299db9ec823/parity-wasm-0.41.0/src/elements/section.rs:289
#18 0x0000000000455ea7 in <parity_wasm::elements::section::TypeSection as parity_wasm::elements::Deserialize>::deserialize (reader=0xa)
    at /home/pierre/.cargo/registry/src/github.com-1ecc6299db9ec823/parity-wasm-0.41.0/src/elements/section.rs:381
#19 0x0000000000455490 in <parity_wasm::elements::section::Section as parity_wasm::elements::Deserialize>::deserialize (reader=0x13acc00 <stack+8363008>)
    at /home/pierre/.cargo/registry/src/github.com-1ecc6299db9ec823/parity-wasm-0.41.0/src/elements/section.rs:95
#20 0x00000000004524a4 in <parity_wasm::elements::module::Module as parity_wasm::elements::Deserialize>::deserialize (reader=0x13acc00 <stack+8363008>)
    at /home/pierre/.cargo/registry/src/github.com-1ecc6299db9ec823/parity-wasm-0.41.0/src/elements/module.rs:538
#21 0x0000000000451a11 in parity_wasm::elements::deserialize_buffer (contents=...) at /home/pierre/.cargo/registry/src/github.com-1ecc6299db9ec823/parity-wasm-0.41.0/src/elements/mod.rs:297
#22 0x00000000004518b0 in wasmi::Module::from_buffer (buffer=...) at /home/pierre/.cargo/git/checkouts/wasmi-11ee91c595aa6a0a/31ac62f/src/lib.rs:552
#23 0x00000000004035f6 in redshirt_core::module::Module::from_bytes (buffer=...) at /home/pierre/Projets/os/core/src/module.rs:39
#24 0x00000000004018a9 in redshirt_standalone_kernel::kernel::Kernel::run (self=<optimized out>) at kernel/standalone/src/kernel.rs:56
#25 0x0000000000401340 in after_boot (multiboot_header=<optimized out>) at kernel/standalone/src/arch/x86_64.rs:51
#26 0x00000000004010cf in _start64 () at src/arch/x86_64/boot.S:115
#27 0x00000004000003f9 in ?? ()
#28 0x001af4ee01080000 in ?? ()
#29 0x0000000acc14001c in ?? ()
#30 0x000000199cba0000 in ?? ()
#31 0x0000000000000000 in ?? ()

Before blaming the allocator, we want to make sure that there isn't a program writing over memory that it isn't supposed to write over.
The hardware handler should get passed a list of physical memory locations that are forbidden.