SchOS/docs/history
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Nexoniarz 51983144e3 exec: Linux's 2 MB of arguments; mmap: merge neighbouring mappings
exec took 32 arguments and 64 environment variables, in fixed arrays,
so a glob over more than 31 files failed with E2BIG. It now reads the
caller's argv and envp where they are, through the uaccess helpers and
a bounce page -- a second thread rewriting the array after a check
cannot slip a kernel address in -- and sizes the new stack to fit
them. The limits are Linux's: ARG_MAX, 2 MB of strings and pointers,
and 128 KB for any one string (USER_STR_MAX follows it).

Every mmap took one of a process's 256 VMA slots, and zsh takes one per
16 KB heap block, so `x=($(<file))` over 30000 words ran out after 4 MB
of heap and exited 1 without a word. Neighbouring anonymous mappings
now share a record, as Linux merges them -- the bump allocator puts
each new one where the last ended -- and munmap trims or splits it.
Partial unmaps of device or segment mappings are refused with EINVAL
instead of kfree()ing pages that are not the process's, and a failed
allocation half way through a mapping no longer leaks what it had.

Checked under QEMU: touch over 3000 names, /bin/echo with 50000
arguments, E2BIG past 2 MB, zsh splitting 100000 words, fork loops.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S1giNvrHTrPMPw7V6x1kQ4
2026-10-23 13:20:29 +02:00
..
kernel.md exec: Linux's 2 MB of arguments; mmap: merge neighbouring mappings 2026-10-23 13:20:29 +02:00
moving-to-linux.md licence: SchOS is GPL-2.0-or-later, no longer Apache-2.0 2026-10-22 08:48:45 +02:00
README.md docs: four directories, and a rule for when a thing leaves the roadmap 2026-09-12 17:13:35 +02:00
schfs.md docs: four directories, and a rule for when a thing leaves the roadmap 2026-09-12 17:13:35 +02:00

History

Why SchOS is the way it is. Bugs whose cause was nowhere near their symptom, and the few write-ups that have nowhere better to live.

kernel.md The expensive ones. Boot, SMP, signals, ABI assumptions, /proc, input.
schfs.md How the filesystem was built, and what each phase cost.
moving-to-linux.md The Windows-to-Fedora move.

What belongs in here

A bug whose cause is not visible from the code that fixed it.

That is the whole test. If reading the fix explains the problem, the fix is the documentation and nothing needs writing down. If the fix looks arbitrary — a constant moved by eight, a field reordered, a check inverted — then the strangeness is load-bearing and the next person to touch it deserves to know why before they change it back.

Every entry here is a thing that looked like a different problem than it was.

What does not belong

  • A changelog. git log is the changelog.
  • A bug that was found and fixed in an hour. Cost is the filter.
  • How something works. That is ../architecture/, written in the present tense for somebody who does not care what it used to be.
  • Anything still open. An unfinished investigation goes in ../plan/ or in the code as a comment. This directory is past tense.

How to write one

Symptom first, then diagnosis, then the fix, then the transferable part.

The transferable part is the reason the entry exists. __thread being wrong for per-CPU data is worth more than the specific null dereference it caused; "a layout constant that several artifacts must agree on wants a check that stops the build, not a comment asking people to remember" is worth more than the bootloader offset that taught it.

Say how it was found, when the technique was the hard part. A hardware watchpoint through QEMU's gdb stub named an instruction on the first run after three rounds of cprintf had narrowed it to nothing — that is reusable, and the bug is not.

Do not clean up the embarrassing part. The near-miss where a change passed every assertion green without having been applied at all is one of the most useful entries in this directory, and it only works because it admits that a grep returning three hits was read as confirmation without counting what they were.