menios
menios copied to clipboard
Page fault handler prints duplicate error messages
Description
When a user page fault occurs, the page fault handler prints each error message multiple times (typically 4 times), cluttering the console output.
Symptoms
- Every page fault error appears 2-4 times
- Makes debugging difficult due to visual noise
- Suggests potential race condition or multiple execution paths
Example Output
User page fault at 0x00000000000000f0 (present=no write=no), terminating pid=3
User page fault at 0x00000000000000f0 (present=no write=no), terminating pid=3
rip=0x000000000042e182 cs=0x003b rflags=0x0000000000010206 rsp=0x0000000000dffe60 ss=0x0043
rip=0x000000000042e182 cs=0x003b rflags=0x0000000000010206 rsp=0x0000000000dffe60 ss=0x0043
User page fault at 0x00000000000000f0 (present=no write=no), terminating pid=3
User page fault at 0x00000000000000f0 (present=no write=no), terminating pid=3
rip=0x000000000042e182 cs=0x003b rflags=0x0000000000010206 rsp=0x0000000000dffe60 ss=0x0043
rip=0x000000000042e182 cs=0x003b rflags=0x000000000010206 rsp=0x0000000000dffe60 ss=0x0043
Possible Causes
- Signal Delivery Loop: Page fault triggers signal delivery which re-triggers page fault handler
- No Exit After First Fault: Process not properly terminated after first fault message
- Re-execution of Faulting Instruction: Handler returns to faulting instruction instead of terminating
- fprintf/stderr Buffering: Multiple flush operations printing buffered content repeatedly
- Process Termination Path: proc_exit() may be re-entered multiple times
- Signal Handler Re-entry: SIGSEGV handler may be getting invoked multiple times
Expected Behavior
Each unique page fault should print error message exactly once before process termination.
Investigation Areas
-
Page fault handler (likely or )
- Check if handler returns vs terminates process
- Verify process state after fault
-
Signal delivery path
- Check if SIGSEGV is delivered correctly
- Verify signal handler doesn't re-fault
-
Process termination
- Ensure proc_exit() is called only once
- Check if process state prevents re-execution
-
Console output
- Check for buffering issues in fprintf/perror
- Verify atomic write operations
Impact
LOW - Cosmetic issue, but makes debugging harder
Priority
MEDIUM - Should be fixed for better diagnostics
Related Issues
- #319 - Doom null pointer crash (where duplicates appear)
- Page fault handler implementation
- Signal delivery system (#103, #210-#213)