Skip to content

Conversation

@ryanbreen
Copy link
Owner

Summary

  • Fix kernel panic at 0xffffc97ffffffff0 during signal delivery after child process termination
  • Change frame_decref() to return false for untracked frames, preventing unsafe deallocation
  • All 138/138 boot stages now pass

Root Cause

The CoW fork implementation (PR #79) introduced a bug where frame_decref() returned true for frames not tracked in the CoW metadata. This caused untracked frames to be freed and potentially reused while still in use by kernel structures, leading to memory corruption.

Fix

Conservative approach: refuse to deallocate untracked frames. This causes a small memory leak for child-allocated pages but prevents corruption. A more complete fix would properly track which frames are safe to deallocate.

Test plan

  • Boot stages test passes (138/138)
  • SIGTERM kill test passes (was first failing test)
  • All CoW-related tests pass

🤖 Generated with Claude Code

The CoW fork implementation was causing kernel panics during signal
delivery after child processes terminated. The root cause was that
frame_decref() returned true for untracked frames, causing them to
be freed even when they might still be in use.

The crash occurred at kernel address 0xffffc97ffffffff0 with
RSP=0xffffc97fffffffe0, indicating memory corruption in the kernel
stack region (PML4[402]).

Fix: Change frame_decref() to return false for untracked frames.
This causes a small memory leak for child-allocated pages but
prevents potential corruption from freeing frames that may still
be in use by kernel structures or other processes.

The conservative approach is necessary because untracked frames
include:
1. Frames allocated by child processes after fork (safe to free)
2. Frames that were never part of CoW sharing (unsafe to free)

Since we cannot distinguish between these cases, we leak rather
than risk corruption. Further investigation is needed to properly
track all frames that are safe to deallocate.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@ryanbreen ryanbreen merged commit 5a9bc74 into main Jan 11, 2026
1 check failed
@ryanbreen ryanbreen deleted the fix/cow-frame-deallocation branch January 11, 2026 00:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants