menios icon indicating copy to clipboard operation
menios copied to clipboard

Page fault handler prints duplicate error messages

Open pbalduino opened this issue 3 months ago • 1 comments

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

  1. Signal Delivery Loop: Page fault triggers signal delivery which re-triggers page fault handler
  2. No Exit After First Fault: Process not properly terminated after first fault message
  3. Re-execution of Faulting Instruction: Handler returns to faulting instruction instead of terminating
  4. fprintf/stderr Buffering: Multiple flush operations printing buffered content repeatedly
  5. Process Termination Path: proc_exit() may be re-entered multiple times
  6. 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

  1. Page fault handler (likely or )

    • Check if handler returns vs terminates process
    • Verify process state after fault
  2. Signal delivery path

    • Check if SIGSEGV is delivered correctly
    • Verify signal handler doesn't re-fault
  3. Process termination

    • Ensure proc_exit() is called only once
    • Check if process state prevents re-execution
  4. 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)

pbalduino avatar Oct 20 '25 01:10 pbalduino