summaryrefslogtreecommitdiff
path: root/src/Registers.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-23 17:10:58 -0300
committerGabriel Schneider <[email protected]>2026-10-23 17:10:58 -0300
commit0073d05329335dbb0eb85f5c3044e42805d144e5 (patch)
tree744edfc317719b2018b1c3a8657c223aec058d47 /src/Registers.zig
parenta8b457a306a4442975210bcac3f04b56513c61c3 (diff)
downloadpardes-0073d05329335dbb0eb85f5c3044e42805d144e5.tar.gz
pardes-0073d05329335dbb0eb85f5c3044e42805d144e5.zip
Callstack lists every caller and pages a tree too big for one query; memory bounds and resident-size fixes
Callstack walks while the server answers, counts on the message row past a second, puts test callers last at each level, and ends a tree past one query's memory (memory.limits.arena.lsp_query, a 256 MiB region taken and given back per query) in a row whose Callstack shows the next page. Grep reads whole files. New hard limits: undo text per file, image decode pixels, the LSP snapshot of other open files, one paste. Safe builds no longer fill worst-case buffers with 0xAA (memory.unfilled), big regions are kept off transparent huge pages, and malloc_trim runs after big results. Also: Look's git show pages into a +Diff, and dropped marks in File. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/Registers.zig')
-rw-r--r--src/Registers.zig13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/Registers.zig b/src/Registers.zig
index 3f2486cd..5e23da5b 100644
--- a/src/Registers.zig
+++ b/src/Registers.zig
@@ -81,6 +81,7 @@ pub fn text(r: *Registers, gpa: std.mem.Allocator, name: u21) ?[]const u8 {
const reg = r.get(name) orelse return null;
if (reg.joined) |j| return j;
var out: std.ArrayList(u8) = .empty;
+ defer out.deinit(gpa); // what a failed append left; empty once owned
for (reg.values, 0..) |v, i| {
if (i > 0 and !std.mem.endsWith(u8, reg.values[i - 1], "\n")) out.append(gpa, '\n') catch return null;
out.appendSlice(gpa, v) catch return null;
@@ -105,3 +106,15 @@ test "a register holds a value per range and joins them for one-text readers" {
try std.testing.expectEqualStrings("x", r.text(gpa, 'a').?);
try std.testing.expectEqualStrings("one\ntwo", r.text(gpa, default).?);
}
+
+test "joining a register that runs out of memory partway leaks nothing" {
+ var r: Registers = .{};
+ defer r.deinit(std.testing.allocator);
+ r.put(std.testing.allocator, default, "one", 0, 2, true);
+ r.put(std.testing.allocator, default, "two", 1, 2, false);
+ r.put(std.testing.allocator, default, &(@as([4096]u8, @splat('x'))), 1, 2, false);
+ // The first append allocates; growing for the 4096 bytes fails.
+ var failing = std.testing.FailingAllocator.init(std.testing.allocator, .{ .fail_index = 1, .resize_fail_index = 0 });
+ try std.testing.expect(r.text(failing.allocator(), default) == null);
+ try std.testing.expectEqual(failing.allocated_bytes, failing.freed_bytes);
+}