From a861809d3581b701c4f06b6cb09fef8b4cdc1039 Mon Sep 17 00:00:00 2001 From: Luis <42945842+ldiaz94@users.noreply.github.com> Date: Mon, 26 Oct 2026 10:48:31 +0000 Subject: [PATCH] PLAN.md: the safety thaw's scope, by the owner's word F.1, the torn slice said in 7.6, []const T with literals typed by it, the fence as import SYSTEM, atomics on a variable, Heap's debugging mode, Task and Guarded; ret/keep, owners, no free and atomic slices left out. PROPOSALS.md and MEM_PROPOSAL.md say so. --- diff --git a/MEM_PROPOSAL.md b/MEM_PROPOSAL.md index faff811..baf5d5a 100644 --- a/MEM_PROPOSAL.md +++ b/MEM_PROPOSAL.md @@ -1,6 +1,6 @@ # MEM_PROPOSAL: a memory-safe raz -**Status.** A proposal, drafted 2026-10-17 for the owner's review. +**Status.** A proposal, drafted 2026-10-17. Reviewed whole by the owner on 2026-10-26: `PLAN.md` §2 says what goes in (F.1, `[]const T`, G, E.4, `Task`, `Guarded`, the fence as `import SYSTEM`) and what is left out (B, C, D, the rest of E). Nothing in it is built. Four adversarial reviews, made the same day, are appendices 4 to 7. They find real holes in the guarantee (appendix 4), wrong and imprecise claims about other languages and diff --git a/PLAN.md b/PLAN.md index 8551ad7..9c93d4a 100644 --- a/PLAN.md +++ b/PLAN.md @@ -27,21 +27,62 @@ ## 2. The safety thaw: v0.23.0 -From `MEM_PROPOSAL.md`, with "Less that is undefined", "A slice that -can't be written: `[]const T`", "What a call does with its arguments" -(its part 3, `ret` and `keep`), and "Left out"'s exported array read as -a slice. +The scope, by the owner's word of 2026-10-26, after reviewing +`MEM_PROPOSAL.md` whole with its appendices. raz doesn't promise memory +safety: `free` stays, so a program can always keep a pointer to what +it freed. The thaw shrinks what is undefined, and fences what can reach +memory it shouldn't, so a reader can find it. + +What goes in: + +- **An array a call returns lives to the end of its procedure** + ("Less that is undefined", piece 1; the proposal's F.1). Its slot is + reserved as a deferred statement's is. +- **A race tears no slice, said**: 7.6 says a slice or variant read and + written in a race is undefined (piece 3). Said, not prevented: no + 16-byte moves. +- **`[]const T`**, a slice whose elements can't be written; a `[]T` + goes where one is wanted, never back. String literals are `[]const + U8`, and a constant's slices `[]const T`, so writing them is an error + (piece 2 drops out). `Str.trim`, `cut` and `field` take and return + `[]const U8`. "Left out"'s exported array read as a slice comes with + it. +- **The fence, Oberon's way**: the unsafe operations are reached + through a pseudo-module, `import SYSTEM`. `SYSTEM.ADR`, `SYSTEM.PTR`, + `SYSTEM.SYSCALL`, `SYSTEM.ARGV`; pointer indexing, slicing and + arithmetic, conversions to and from pointer and procedure types, + views whose type holds a pointer, procedure or slice, `extern`, + `link`, code procedures and `check off` are allowed only in a module + that imports it. A warning for one release, so that `src/` can come + to it once `BOOT` knows it, then an error. +- **`CAS`, `XCHG` and `XADD` take a variable**, as `INC` does, not an + address (the proposal's E.4), so atomics need no `SYSTEM`. +- **Library**: `Heap`'s debugging mode (G: freed blocks poisoned and + held back, guard bytes checked); `Task(T)`, a thread started with no + cast; `Lock.Guarded(T)`, a value with its lock. + +What is left out, and why: `ret` and `keep` (B) and owners that count +what they lend (C), too large for what they close without the rest; +the heap without `free` (D), since `free` stays; atomic slices and the +rest of threads (E), for programs that race only. With them the +guarantee of the proposal's section 3. -1. The owner chooses the scope. The proposal's parts stand alone: - A, the fence (`unsafe;`, which modules may reach memory they - shouldn't); B, lending (`ret` and `keep`, the returned-slice hole - closed); C, owners that count what they lend. Appendices 4 to 7 find - holes in its body, and C is much the largest. A then B, each a step - of its own, is the smaller way. -2. The body of what is chosen is revised against its appendices. -3. The report's text, for the owner to review; then the compiler, the - library, and the programs in `~/r` it breaks, each mended. -4. Release, and the report's pages checked. +The survey of 2026-10-26 (the compiler counting each use, across +`~/r`): about 8,000 fenced uses, 451 of 960 modules. 77% of the `ADR`s +go to a pointer parameter only dereferenced, mended by `var` or +`const`, as `STANDARDS.md` asks; what is left for `SYSTEM` is about +3,000 uses, most in `lib/` (`Sys`, `Rt`, `Heap`, `Map`) and `src/` +(`Scan`, `Link`, `Chunk`). All 31 atomics take `ADR`. + +1. The report's text, for the owner to review. +2. `tools/Mutate.raz` taught the two rewrites: `ADR` at a parameter + only dereferenced to `var` or `const`, and `SYSTEM.` where an + address is kept. +3. The compiler, a commit a piece; the library; the programs in `~/r` + it breaks, each mended. +4. Release, and the report's pages checked; then, a step of its own, + `BOOT` moved, `src/` imports `SYSTEM`, and the warning becomes an + error. ## 3. The Moss work: v0.24.0 diff --git a/PROPOSALS.md b/PROPOSALS.md index 6542204..7d4bee9 100644 --- a/PROPOSALS.md +++ b/PROPOSALS.md @@ -70,7 +70,8 @@ 2026-10.33 on their own, without the marks: the library's parameters by `var` (part 2), a `const` parameter (part 4), and a variant in a constant (part 5). What is left are the two parts not approved, kept -by their numbers: +by their numbers. Left out of the safety thaw by the owner on 2026-10-26 +(`PLAN.md` §2). 1. **Marks at the call** (this section): an argument for a `var` parameter is written `var x`, and one for a `keep` parameter @@ -939,7 +940,7 @@ ## Less that is undefined -**Status.** Parked by the owner on 2026-10-23 for the safety thaw that follows once the proposals are cleared, with `MEM_PROPOSAL.md`. +**Status.** Decided by the owner on 2026-10-26 for the safety thaw (`PLAN.md` §2): pieces 1 and 3 (said, not prevented) go in; 2 is answered by `[]const T`; 4 goes in as `import SYSTEM`. Section 10 lists what isn't defined: a stale or made-up pointer, indexing through a pointer, a slice kept after its frame is gone, a @@ -1065,7 +1066,7 @@ ## A slice that can't be written: `[]const T` -**Status.** Parked by the owner on 2026-10-23 for the safety thaw that follows once the proposals are cleared, with `MEM_PROPOSAL.md`. +**Status.** Decided by the owner on 2026-10-26 for the safety thaw (`PLAN.md` §2): it goes in, string literals and a constant's slices typed by it, `Str.trim`, `cut` and `field` returning `[]const U8`. raz has no slice whose elements can't be written. A `const` parameter (report 2026-10.33, section 8) is shallow: the procedure can't change @@ -2905,7 +2906,7 @@ - Records don't compare with `=` — padding, reals (`-0.0`, NaN) and slices make a byte compare wrong; a `same` procedure says what equal means. Confirmed by the owner, 2026-10-22. - No type of its own for an array — a one-field record keeps two hashes apart, as it keeps generic arrays (owner's idiom). - No exporting a record's fields as a whole — each `*` is the reader's mark of what is public; `Mxlib` is a C mirror, made by a program. -- An exported array can't be read as a slice outside its module — a slice can be written through; "A slice that can't be written: `[]const T`" in PROPOSALS.md would answer it. Parked by the owner on 2026-10-23, with `[]const T`, for the safety thaw. +- An exported array can't be read as a slice outside its module — a slice can be written through; "A slice that can't be written: `[]const T`" in PROPOSALS.md would answer it. Comes with `[]const T` in the safety thaw (`PLAN.md` §2). - An exported variable can't be assigned from outside — Oberon's read-only export; a setter shows who writes. - A generic instance isn't reachable through the module that imported it — no bug: an import's name is never exported (3); export a type of the instance, or import it again. - `I32` doesn't widen to `INT` — `INT` may be 16 bits (5.1), so the widening would not hold everywhere.