robert-w-gries / rxinu

Rust implementation of Xinu educational operating system

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Page fault while trying to deallocate kstack

robert-w-gries opened this issue · comments

rxinu code that triggers issue

    fn kill(&self, id: ProcessId) {
            [snip]
            proc_lock.kstack = None;  // This line page faults

Error message

ExceptionStack {
    error_code: 0x0,
    instruction_pointer: 0x13c16f,
    code_segment: 0x8,
    cpu_flags: 0x6,
    stack_pointer: 0x40005dd0,
    stack_segment: 0x6
}
InterruptDescription {
    vector: 14,
    mnemonic: "#PF",
    description: "Page Fault",
    irqtype: "Fault",
    source: "Any memory reference."
}

Instruction Pointer

0013c160 <_ZN21linked_list_allocator4hole4Hole4info17h2969c3bff7ef9cc1E>:
  13c160:	55                   	push   %ebp
  13c161:	89 e5                	mov    %esp,%ebp
  13c163:	83 ec 10             	sub    $0x10,%esp
  13c166:	8b 45 08             	mov    0x8(%ebp),%eax
  13c169:	89 45 f4             	mov    %eax,-0xc(%ebp)
  13c16c:	8b 45 f4             	mov    -0xc(%ebp),%eax
>>13c16f:	8b 08                	mov    (%eax),%ecx
  13c171:	89 45 f8             	mov    %eax,-0x8(%ebp)
  13c174:	89 4d fc             	mov    %ecx,-0x4(%ebp)
  13c177:	8b 45 f8             	mov    -0x8(%ebp),%eax
  13c17a:	8b 55 fc             	mov    -0x4(%ebp),%edx
  13c17d:	83 c4 10             	add    $0x10,%esp
  13c180:	5d                   	pop    %ebp
  13c181:	c3                   	ret    

Seems like it's a more general issue with the allocator calls. I commented out the process.kstack = None line and saw the same issue come up in a different location.

rxinu::rust_main (multiboot_information_address=2667712) at src/lib.rs:62
62	    for i in 0..max_procs {
(gdb) s
63	        syscall::create(test_process, format!("test_process_{}", i));
(gdb) s
core::fmt::ArgumentV1::new<i32> (x=0x14ffa0, 
    f=0x111110 <core::fmt::num::<impl core::fmt::Display for i32>::fmt>)
    at /home/rob/.rustup/toolchains/nightly-2017-12-23-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/fmt/mod.rs:309
309	                formatter: mem::transmute(f),
(gdb) 
310	                value: mem::transmute(x)
(gdb) 
308	            ArgumentV1 {
(gdb) 
313	    }
(gdb) 
core::fmt::Arguments::new_v1_formatted (pieces=..., args=..., fmt=...)
    at /home/rob/.rustup/toolchains/nightly-2017-12-23-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/fmt/mod.rs:363
363	            pieces,
(gdb) 
364	            fmt: Some(fmt),
(gdb) 
365	            args,
(gdb) 
362	        Arguments {
(gdb) 
367	    } // Page Fault here
(gdb) 

i686 support has been dropped for now. Will re-open this if it's an issue later