From e6e81a6bc544c5ab5a47c21d85e6868020031abb Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 17 Nov 2026 01:18:56 -0300 Subject: regexp: a class's range may end at \xff: mvzr counted `c1..c2 + 1` in a u8, which overflowed at 0xff (a panic in a safe build, a loop past its bounds in a fast one), so `[\x80-\xff]` in any search, an address, s or S, a plumbing rule, took the editor down; build.zig's patch of mvzr widens the count to usize, beside its other patches (one occurrence, checked); found writing the plumber's rules, whose classes for UTF-8 names the design record wrote as \x80-\xff; test: a class of a-z and the high bytes finds café, [\xff-\xff] compiles; the changelog says so MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- build.zig | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'build.zig') diff --git a/build.zig b/build.zig index d99f3985..acd402b6 100644 --- a/build.zig +++ b/build.zig @@ -400,7 +400,11 @@ pub fn build(b: *std.Build) void { if (std.mem.count(u8, backed, end_anchor) != 1) @panic("mvzr's parser changed: redo its `$` before `|` in build.zig"); var patched = std.mem.replaceOwned(u8, b.allocator, backed, end_anchor, end_before_alt) catch @panic("OOM"); // Zig 0.17 removed `**`; mvzr still has it (its PR #16 replaces it upstream). + // A class's range ending at `\xff` counted to 256 in a u8, an + // overflow (a panic in a safe build, a runaway loop in a fast one): + // `[\x80-\xff]` in any search took the editor down. for ([_][3][]const u8{ + .{ "for (c1..c2 + 1) |c_range|", "for (c1..@as(usize, c2) + 1) |c_range|", "1" }, .{ "[1]RegOp{.{ .unused = {} }} ** ops", "@splat(.{ .unused = {} })", "1" }, .{ "[1]CharSet{.{ .low = 0, .hi = 0 }} ** char_sets", "@splat(.{ .low = 0, .hi = 0 })", "1" }, .{ "\"a\" ** 2048", "&@as([2048]u8, @splat('a'))", "2" }, -- cgit v1.3