SchOS/kernel
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Nexoniarz 3eed58fe9b kernel: holdingsleep asks who holds the lock, not whether anyone does
int r = lk->locked;                              // before
    int r = lk->locked && lk->pid == myproc()->pid;  // after

Seven callers, and every one of them is an assertion of the form

    if (!holdingsleep(&b->lock)) panic("brelse");

whose entire purpose is to catch a process releasing a lock it never took.
Answering the weaker question disarms all of them: iunlock() on an inode locked
by another process, and brelse() on somebody else's buffer, both sailed through
and unlocked it underneath the real holder. Two processes then believe they hold
the same inode, and the corruption surfaces somewhere else entirely -- which is
exactly the shape of bug these panics exist to prevent.

Found while hunting the ls -lR hang. It is not proven to be that hang's cause,
and the instrumentation in the next commits says it is probably not. It is a
real defect regardless, and it re-arms the detector that would catch the rest.

myproc() is null on the boot path before the scheduler runs and acquiresleep()
stores 0 for that case, so this compares the same way rather than dereferencing
null. Checked that nothing touches a buffer that early, so the stricter
assertion cannot fire spuriously on boot.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VQ7Qx8E1q1M1bbCq8QLHS2
2026-09-12 17:13:59 +02:00
..
arch/x86_64 docs: four directories, and a rule for when a thing leaves the roadmap 2026-09-12 17:13:35 +02:00
core kernel: holdingsleep asks who holds the lock, not whether anyone does 2026-09-12 17:13:59 +02:00
dev gfx: the console and the crash screen stop drawing on a driver by name 2026-08-15 17:04:10 +02:00
drivers docs: four directories, and a rule for when a thing leaves the roadmap 2026-09-12 17:13:35 +02:00
fs test: the network is checked by the suite now, and /proc/netif says what it did 2026-08-15 16:11:49 +02:00
net net: a network *class*, so the stack stops knowing what an e1000 is 2026-08-15 16:42:34 +02:00
proc docs: four directories, and a rule for when a thing leaves the roadmap 2026-09-12 17:13:35 +02:00
sys gfx: the console and the crash screen stop drawing on a driver by name 2026-08-15 17:04:10 +02:00
kernel.ld Initial commit: Schunix as it stands before the SchOS rename 2026-08-09 13:47:01 +02:00