summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-18 07:09:32 -0300
committerGabriel Schneider <[email protected]>2026-11-18 07:09:32 -0300
commitf0e6eb0de0b5ac9f81ba2c728f3040c4a51ab284 (patch)
treee2660cddde27b7dc03240e6c56ceefad1ffc35fe /addons
parent3350156db428656fa8e583d1971663e1c4a215b0 (diff)
downloadpardes-f0e6eb0de0b5ac9f81ba2c728f3040c4a51ab284.tar.gz
pardes-f0e6eb0de0b5ac9f81ba2c728f3040c4a51ab284.zip
kinds: a kind's job tokens are the session's on every core, a client's plain kind keeps no job's input, and a PDF render's pixels go with the document they are of: Slot.tokens is dumped and digested (a client joined later numbers its next job as the session does; a Shadow takes it from the call's outcome), api.job on a replica gives the token alone (it runs no job, so its four input slots filled and it refused the fifth while the session asked on), and a render's answer names its document, so one that lands after its pane opened its file again (changed on disk) no longer frees pixels the old document freed with it (a double free, ABRT in the new behaviour test without the fix); kitty-harness's panic placed: the base's (the harness panics before its first line when NO_COLOR is in its environment, as zig build gives it; run by hand without it, it passes on the base and on this tree); tui core-test 820/959 (139 skipped), shell-test 994/997, behaviour-test 274/274 and --replay 0 failures, pane-test 180/181, addon-test 1/1, replicas pass (checked/wrong 0)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'addons')
-rw-r--r--addons/pdf/pdf.zig11
1 files changed, 7 insertions, 4 deletions
diff --git a/addons/pdf/pdf.zig b/addons/pdf/pdf.zig
index 45f1e22a..d7125de5 100644
--- a/addons/pdf/pdf.zig
+++ b/addons/pdf/pdf.zig
@@ -709,7 +709,9 @@ pub const Pdf = struct {
const In = extern struct { op: Op, cookie: u32 = 0, doc: u64 = 0, page: u32 = 0, tint: Tint = .disabled, req: Request = std.mem.zeroes(Request), band_y: u32 = 0, band_h: u32 = 0, ink: u32 = 0, paper: u32 = 0, keep_clean: u32 = 0, n: u32 = 0 };
/// A job's answer, and after it the sizes (sizes), the text (text), the
/// quads (hits), or each page's count of hits and the rows (search).
- const Out = extern struct { ok: u32 = 0, busy: u32 = 0, w: u32 = 0, h: u32 = 0, band_y: u32 = 0, band_h: u32 = 0, n: u32 = 0, hits: u32 = 0, rgba: ?[*]u8 = null, clean: ?[*]u8 = null };
+ /// (`doc`: the document a render's pixels are of: one closed since,
+ /// a file changed on disk, freed them with it.)
+ const Out = extern struct { ok: u32 = 0, busy: u32 = 0, w: u32 = 0, h: u32 = 0, band_y: u32 = 0, band_h: u32 = 0, n: u32 = 0, hits: u32 = 0, doc: u64 = 0, rgba: ?[*]u8 = null, clean: ?[*]u8 = null };
/// On a worker: the job on a free lane of its document.
pub fn jobRun(bytes: []const u8, gpa: std.mem.Allocator) ?[]u8 {
@@ -780,7 +782,8 @@ pub const Pdf = struct {
const res = if (bytes.len >= @sizeOf(Out)) std.mem.bytesToValue(Out, bytes[0..@sizeOf(Out)]) else Out{};
const extra = bytes[@min(bytes.len, @sizeOf(Out))..];
const len = @as(usize, res.w) * 4 * res.band_h;
- const px: [2][]u8 = .{ if (res.rgba) |p| p[0..len] else &.{}, if (res.clean) |p| p[0..len] else &.{} };
+ const ours = res.doc == d.id;
+ const px: [2][]u8 = .{ if (res.rgba) |p| (if (ours) p[0..len] else &.{}) else &.{}, if (res.clean) |p| (if (ours) p[0..len] else &.{}) else &.{} };
for (px) |p| claim(d, p);
var kept = false; // (the pixels, a page's slot's)
defer if (!kept) for (px) |p| heap.free(p);
@@ -835,7 +838,7 @@ pub const Pdf = struct {
if (s.job.token == token and s.view != 0) break s;
} else return;
s.job.token, s.job.failed = .{ 0, res.ok == 0 and res.busy == 0 };
- if (res.ok == 0) return;
+ if (res.ok == 0 or !ours) return;
for ([_][]const u8{ s.rgba, s.clean, std.mem.sliceAsBytes(s.shown) }) |p| heap.free(p);
const v = st.views[s.view - 1].v;
st.revs += 1;
@@ -888,7 +891,7 @@ fn render(d: *Doc, ld: ?*m.pardes_pdf_document, in: *const Pdf.In, marks: []cons
};
docs_lock.unlock();
if (kept) {
- res.* = .{ .ok = 1, .w = @intCast(L.width), .h = full, .band_y = by, .band_h = bh, .rgba = px.ptr, .clean = if (clean.len > 0) clean.ptr else null };
+ res.* = .{ .ok = 1, .w = @intCast(L.width), .h = full, .band_y = by, .band_h = bh, .doc = d.id, .rgba = px.ptr, .clean = if (clean.len > 0) clean.ptr else null };
return;
}
for ([_][]u8{ px, clean }) |p| {