diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-22 18:06:54 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-22 18:27:49 -0300 |
| commit | 19386feb0074afc1afed6e8ebe8596c426e4bdb0 (patch) | |
| tree | eb4be79ab8f258dd0ef3b52332355063b7549696 /build | |
| parent | f60f51fe89f1d3737389047cb2f3671b1b21e56d (diff) | |
| download | pardes-19386feb0074afc1afed6e8ebe8596c426e4bdb0.tar.gz pardes-19386feb0074afc1afed6e8ebe8596c426e4bdb0.zip | |
mvzr: what it compiles it can walk: three Edits in build/patches.zig (docs/mvzr-empty-group.md, the report for upstream, its patch checked against trunk 3efcfe33): `patternAcceptsEmpty` answers true for an empty pattern (a group with nothing inside and more after it took `groupAcceptsEmpty`'s alternatives branch, `hasAlt` counting the group's own `)`, whose last line asked the empty inside for its first operation: `()a` searched to a line's end, the soak's abort); `prefixModifier` refuses a repeat right after `^` or `|`, as it refuses one at the start (its test read `patt[j]`, the slot being written, where `patt[j - 1]` was meant: `^*` compiled to `star, begin`, which the matcher holds unreachable, and `a|*` to `a, star, alt`, whose first alternative's lone `star` had nothing to repeat); a count followed by anything but `,` or `}` is a bad string (`{1` then any other character wrote no operation and skipped that character, a hole that ended the program: `a{1b` ran as `a`, `({1))` as a lone `(`); a user hits the first by typing `()` and one more character into `s` or `/` over a line it does not match (a safe build's session aborts, the installed one too: the same pin and the same Edits), the second by typing `a|*` or `^*`, the third by `({1))`; with the Edits the drive outside the tree finds no panic in 11,588,883 patterns (up to seven characters over `()|*+?a`, six over `()|*+?a^$.{}1`, five over `()[]{},*+?|\^$.-a1xnbf`, from every offset of three short texts; 18,746, 68,627 and 40,135 on the base), no search out of budget, every match inside its text, and the patterns it newly refuses are exactly those with a repeat right after `|` or `^` (up to six over `()|*+?a`: 4,068 of the base's 8,778 compiled, 3,096 of them panicked; the rest were the same miscompile on texts that did not reach it); mvzr's own tests on an upstream copy (its four `**` replaced for Zig 0.17) 32/32 with the report's test, 31 and an abort at `patternAcceptsEmpty` without the Edits; mvzr's trunk on this machine (~/05-genizah/mvzr, origin/trunk 3efcfe33, the pin) has none of it, and nothing newer could be looked at here; the previous change's test passes; core-test 917/1074 (157 skipped), shell-test 1116/1119 (3 skipped), each the base's plus that test; the soak that found it (`replicas --clients 5`, TMPDIR /tmp/claude-1000/rs2, load 2-4) ends: diverged 0/0/0, unequal 0/0/0, quiet checks 546/0 442/0 666/0, unlisted stops 0/0/0, the corpus scene 22 of 22, no leak, no panic (1,054 patterns refused in words on the way, 584 of them `missing closing parenthesis`); left as they are (in the report): `patternAcceptsEmpty` judges a sequence by its first operation (`x(a*b)` matches `x`; `(()a)` now matches the empty string at the end of `b`, where it aborted), and a repeat right after `(` takes the `(` (`(*a)` compiles as `(a)*`), neither a panic
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'build')
| -rw-r--r-- | build/patches.zig | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/build/patches.zig b/build/patches.zig index 7d87b9f1..410d27ab 100644 --- a/build/patches.zig +++ b/build/patches.zig @@ -356,6 +356,15 @@ pub fn ghosttyKitty(b: *std.Build, patch: *std.Build.Step.Compile, dep: *std.Bui /// could compile one typed pattern differently. Unreported upstream as /// of 3efcfe33 (its trunk on 2026-11-19); docs/mvzr-bounds.md is the /// report for it. +/// - Three kinds of pattern the matcher indexed an empty slice on (a panic +/// in a safe build, at a key typed into `s` or `/`): an empty group with +/// more after it (`()a`, `a()b`: whether the group may match nothing was +/// asked of its inside's first operation, which it has not got); a +/// repeat right after `|` or `^` (`a|*`, `|??`, `^*`: it took the `|` or +/// the `^` for what it repeats; at the pattern's start it was already +/// refused); and a count that ends in neither `,` nor `}` (`({1))`: the +/// character after it was skipped and a hole left in the program, which +/// ends it there). docs/mvzr-empty-group.md is the report for upstream. const mvzr_edits = [_]Edit{ .{ .old = "fn matchPattern(patt: []const RegOp, sets: []const CharSet, haystack: []const u8, i_in: usize) ?OpMatch {\n", @@ -419,6 +428,12 @@ const mvzr_edits = [_]Edit{ .{ .old = "fn valueFor(in: []const u8) ?u8 {\n", .new = "fn valueFor(in: []const u8) ?u8 {\n if (in.len == 0) return null;\n" }, .{ .old = " return parseHex(in[1..4]) catch return null;\n", .new = " return parseHex(in[1..3]) catch return null;\n" }, .{ .old = " if (i == in.len or in[i] != ']') {\n return BadString;\n", .new = " if (i >= in.len or in[i] != ']') {\n return BadString;\n" }, + // What compiles is a program the matcher can walk: an empty pattern + // accepts the empty string; a repeat repeats an operation; a count is + // closed. + .{ .old = "fn patternAcceptsEmpty(patt: []const RegOp) bool {\n", .new = "fn patternAcceptsEmpty(patt: []const RegOp) bool {\n if (patt.len == 0) return true;\n" }, + .{ .old = " if (j == 0 or patt[j] == .begin) return BadString;\n", .new = " if (j == 0 or patt[j - 1] == .begin or patt[j - 1] == .alt) return BadString;\n" }, + .{ .old = " } else if (in[i] == '}') {\n // {M}\n", .new = " } else if (in[i] != '}') {\n bad_string = true;\n break :dispatch;\n } else {\n // {M}\n" }, .{ .old = "for (c1..c2 + 1) |c_range|", .new = "for (c1..@as(usize, c2) + 1) |c_range|" }, .{ .old = "[1]RegOp{.{ .unused = {} }} ** ops", .new = "@splat(.{ .unused = {} })" }, .{ .old = "[1]CharSet{.{ .low = 0, .hi = 0 }} ** char_sets", .new = "@splat(.{ .low = 0, .hi = 0 })" }, |
