|
|
@@ -16,31 +16,52 @@ Harness: `tools/v3-corpus/corpus.sh` (copies each file to a scratch
|
|
|
tree, compiles alone, splits failures into CRASH / LIB / LANG — see its
|
|
|
README).
|
|
|
|
|
|
-## Baseline
|
|
|
+## Baseline (after the crash fix)
|
|
|
|
|
|
| | files |
|
|
|
| --- | --- |
|
|
|
| total | **612** |
|
|
|
| **compile-OK** (0 errors) | **219** |
|
|
|
-| CRASH (M2 died, rc ≥ 128) | **7** |
|
|
|
-| LIB (imports a gm2 library V3 lacks) | **182** |
|
|
|
-| LANG (real V3 gap) | **204** |
|
|
|
+| CRASH (M2 died, rc ≥ 128) | **0** |
|
|
|
+| LIB (imports a gm2 library V3 lacks) | **187** |
|
|
|
+| LANG (real V3 gap) | **206** |
|
|
|
|
|
|
-So ~182 of the 393 failures are simply **missing gm2 libraries**
|
|
|
-(`StrIO`, `NumberIO`, `STextIO`, `SWholeIO`, `FpuIO`, `WholeStr`,
|
|
|
-`StdIO`, `M2RTS`, `DynamicStrings`, `Processes`, …) — expected, not
|
|
|
-language gaps. The signal is the **204 LANG** files.
|
|
|
+(Before the fix: 219 OK / **7 CRASH** / 182 LIB / 204 LANG.) So ~187
|
|
|
+of the 393 failures are simply **missing gm2 libraries** (`StrIO`,
|
|
|
+`NumberIO`, `STextIO`, `SWholeIO`, `FpuIO`, `WholeStr`, `StdIO`,
|
|
|
+`M2RTS`, `DynamicStrings`, `Processes`, …) — expected, not language
|
|
|
+gaps. The signal is the **206 LANG** files.
|
|
|
|
|
|
-## Top LANG gaps (from the corpus)
|
|
|
+## Fix: long-line buffer overflow (the 7 "set crashes")
|
|
|
+
|
|
|
+The 7 crashes (`largeset`, `program2`, `set9`, `sets3`,
|
|
|
+`smallset4/5/6`) were **not** set bugs: those files contain a ~860-char
|
|
|
+line (a 76-literal enumeration), and
|
|
|
+
|
|
|
+- `PrintListing`'s line buffer was `ARRAY [0 .. 255] OF CHAR`, and
|
|
|
+- `GetLine` wrote **without bounding** to `HIGH(line)`.
|
|
|
+
|
|
|
+A source line longer than 255 chars therefore **overflowed the stack**
|
|
|
+(corrupting locals and the return address) — hence the garbage line
|
|
|
+number in the `.LST` and the segfault.
|
|
|
+
|
|
|
+Fixed in `compiler/src/compiler.frm`:
|
|
|
+- `GetLine` now truncates at `HIGH(line)` (still consuming the rest of
|
|
|
+ the line so positions stay correct);
|
|
|
+- `PrintListing`'s buffer is now `ARRAY [0 .. 4095] OF CHAR`;
|
|
|
+- `PrintErr`'s caret loop is bounded by `HIGH(line)`.
|
|
|
+
|
|
|
+Regression test: `compiler/tests/t_longline.mod` (406-char line, exit
|
|
|
+0). Suite **152/152**; fixpoint OK (2,339,115 bytes).
|
|
|
+
|
|
|
+## Top remaining LANG gaps (from the corpus)
|
|
|
|
|
|
-- **7 crashes** — all set-related: `largeset`, `program2`, `set9`,
|
|
|
- `sets3`, `smallset4/5/6`. Real bugs (segfaults), highest priority.
|
|
|
- **48 `not supported yet`** — deliberate V3 `230`s; the corpus shows
|
|
|
which constructs matter, e.g. **array constructors**
|
|
|
(`array {'h','e','l','l','o'}` in `arrayconst1`).
|
|
|
-- **79 `undeclared identifier`** — mostly **`SYSTEM` facilities** V3
|
|
|
- does not expose (`FROM SYSTEM IMPORT BYTE;` → `BYTE`), plus small
|
|
|
- library holes.
|
|
|
+- **`undeclared identifier`** — mostly **`SYSTEM` facilities** V3 does
|
|
|
+ not expose (`FROM SYSTEM IMPORT BYTE;` → `BYTE`), plus small library
|
|
|
+ holes.
|
|
|
- **Anchored subranges** `INTEGER [-1 .. 24]` (`array2`, `array3`) —
|
|
|
PIM form V3's `Subrange` does not parse (`';' expected` at `[`).
|
|
|
- **Unnamed parameters in procedure types**
|
|
|
@@ -53,19 +74,19 @@ language gaps. The signal is the **204 LANG** files.
|
|
|
|
|
|
```sh
|
|
|
cd tools/v3-corpus
|
|
|
-./corpus.sh # -> 219 compile-OK / 7 CRASH / 182 LIB / 204 LANG
|
|
|
+./corpus.sh # -> 219 compile-OK / 0 CRASH / 187 LIB / 206 LANG
|
|
|
```
|
|
|
|
|
|
## Suggested next steps
|
|
|
|
|
|
-1. **Fix the 7 set crashes** (a correctness bug — a compiler must not
|
|
|
- segfault on valid input).
|
|
|
-2. **`SYSTEM` facilities**: expose at least `BYTE` / `WORD` /
|
|
|
+1. **`SYSTEM` facilities**: expose at least `BYTE` / `WORD` /
|
|
|
`SHORTADDR` etc. so `FROM SYSTEM IMPORT …` works.
|
|
|
-3. **Anchored subranges** `T[lo..hi]` (small grammar addition).
|
|
|
-4. **Unnamed proc-type parameters** (small grammar addition).
|
|
|
-5. **Array constructors** `array{…}` (bigger: codegen).
|
|
|
+2. **Anchored subranges** `T[lo..hi]` (small grammar addition).
|
|
|
+3. **Unnamed proc-type parameters** (small grammar addition).
|
|
|
+4. **Array constructors** `array{…}` (bigger: codegen).
|
|
|
|
|
|
## Files
|
|
|
|
|
|
-`tools/v3-corpus/{corpus.sh,README.md}`, this doc.
|
|
|
+`tools/v3-corpus/{corpus.sh,README.md}`,
|
|
|
+`compiler/src/compiler.frm` (long-line fix),
|
|
|
+`compiler/tests/t_longline.mod`, `compiler/run_tests.sh`, this doc.
|