robert-w-gries / rxinu

Rust implementation of Xinu educational operating system

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Changing process stack size causes strange page faults

robert-w-gries opened this issue · comments

In #64 I increased the process stack size as a hacky workaround for an issue where we hit a Page Fault after running about a dozen processes.

Error

It looks like the kernel gets into a bad state because the instruction pointer is a bad value.

In main process!

................
Error code: (empty)
ExceptionStack {
    instruction_pointer: 0x0,
    code_segment: 0x8,
    cpu_flags: 0x2,
    stack_pointer: 0x40004730,
    stack_segment: 0x10
}
InterruptDescription {
    vector: 14,
    mnemonic: "#PF",
    description: "Page Fault",
    irqtype: "Fault",
    source: "Any memory reference."
}

Page fault while accessing 0x0

Changes needed to hit issue

diff --git a/src/main.rs b/src/main.rs
index 23de134..bc5caec 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -81,7 +81,7 @@ pub extern "C" fn rxinu_main() {
     arch::console::clear_screen();
 
     kprintln!("In main process!\n");
-    syscall::create(created_process, String::from("rxinu_test"));
+    syscall::create(cycle_process_a, String::from("rxinu_test"));
 }
 
 pub extern "C" fn test_process() {
diff --git a/src/task/mod.rs b/src/task/mod.rs
index 9281f74..593cf94 100644
--- a/src/task/mod.rs
+++ b/src/task/mod.rs
@@ -19,7 +19,7 @@ pub trait Scheduling {
 
 const MAX_PROCS: usize = usize::max_value() - 1;
 // TODO: Investigage requirements for size of stack
-const INIT_STK_SIZE: usize = 1024 * 2;
+const INIT_STK_SIZE: usize = 1024 * 1;
 
 lazy_static! {
     pub static ref SCHEDULER: Scheduler = Scheduler::new();

After #66, I am able to increase the process stack size without issue. However, I still see the page fault when the process stack size is set to 1KB.

Fixed by #74