Summary
The scheduler reap path does not appear to use the full process resource cleanup path. scheduler_cleanup_process frees some process-owned data, but can skip file descriptor cleanup and user VM region release.
That can leak file references, VM regions, and physical pages after terminated tasks are reaped.
Current Notes
Tracked locally in scheduler_issues.md as "Process Teardown Leaks Resources".
Relevant code:
src/kernel/proc/proc.c: scheduler_cleanup_process
src/kernel/proc/proc.c: proc_free_resources
src/kernel/proc/proc.c: proc_file_table_cleanup
src/kernel/proc/proc.c: proc_release_user_memory
Expected Behavior
A terminated process should release all owned resources exactly once when reaped, including stacks, file descriptors, VM regions, address-space mappings, and any process table entries.
Proposed Fix
Reuse proc_free_resources from scheduler_cleanup_process, or refactor teardown into a single helper with explicit ownership stages so scheduler reap, exec failure, and process exit paths cannot drift apart.
The fix should preserve zombie/wait semantics: resources that must remain visible to the parent should stay until wait, while heavyweight runtime resources should be released promptly and consistently.
Dependencies
Blocks
Related Issues
Validation
- Add or update tests for process exit/reap resource cleanup where practical.
- Stress repeated fork/exec/exit/wait cycles and inspect memory/file reference behavior.
- Boot smoke test after userland process churn.
- Confirm
make test still passes.
Summary
The scheduler reap path does not appear to use the full process resource cleanup path.
scheduler_cleanup_processfrees some process-owned data, but can skip file descriptor cleanup and user VM region release.That can leak file references, VM regions, and physical pages after terminated tasks are reaped.
Current Notes
Tracked locally in
scheduler_issues.mdas "Process Teardown Leaks Resources".Relevant code:
src/kernel/proc/proc.c:scheduler_cleanup_processsrc/kernel/proc/proc.c:proc_free_resourcessrc/kernel/proc/proc.c:proc_file_table_cleanupsrc/kernel/proc/proc.c:proc_release_user_memoryExpected Behavior
A terminated process should release all owned resources exactly once when reaped, including stacks, file descriptors, VM regions, address-space mappings, and any process table entries.
Proposed Fix
Reuse
proc_free_resourcesfromscheduler_cleanup_process, or refactor teardown into a single helper with explicit ownership stages so scheduler reap, exec failure, and process exit paths cannot drift apart.The fix should preserve zombie/wait semantics: resources that must remain visible to the parent should stay until wait, while heavyweight runtime resources should be released promptly and consistently.
Dependencies
Blocks
Related Issues
Validation
make teststill passes.