diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-23 17:58:08 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-23 18:05:08 -0300 |
| commit | 2d54f7ff16f353ec8267133a9159591fbeca9f8d (patch) | |
| tree | ce5c00e973ad49f18cbd6183efa5f3662ce4b41c /test | |
| parent | 4eb608b0c1f231005237b0f57283d22bfccee0a9 (diff) | |
| download | pardes-2d54f7ff16f353ec8267133a9159591fbeca9f8d.tar.gz pardes-2d54f7ff16f353ec8267133a9159591fbeca9f8d.zip | |
addons: a Zig addon's panic is pardes's panic, and a segmentation fault leaves a crash record: RUN on the base (a throwaway Debug build whose snake addon panics at its open, a tui session in a pty of its own, Snake sent over its 9P; .scratch kept/i5-addon-panic-throw): the session died with the trace on the terminal, NO CRASH RECORD, the terminal LEFT RAW (`-isig -icanon -iexten -echo -opost`, the alternate screen and the mouse modes still on: the shell after it took no line), `pardes new` exited 0, the daemon kept the shell ("shells no session holds"); the cause: a library kind is its own root, so its `@panic` ran std's handler, never runtime/main.zig's (replica.dying, vaxis.recover, crash.record); THE CHANGE: the ABI's pa_api gains `panic` (3.3, at its end, checked by api->size as `draw` is; an addon of 3.2 loads as ever, a 3.3 addon on an older pardes keeps std's handler), the core's entry (core/Kind.zig) `@panic`s with the addon's words ("an addon's panic: ...") so the host's root handler runs, and abi/addon.zig's `panic` is a handler that calls it, which every Zig addon's root names (`pub const panic = addon.panic;`: pdf, image, life, snake, snake_shader, test/liar, test/veil, and the example in addon.zig's head); runtime/main.zig `debug.handleSegfault` writes the crash record too (a fault in C code: MuPDF, stb, tree-sitter, an addon's library); RUN on the change (kept/i5-addon-panic-fixed): the record written ("panic: an addon's panic: addon panic: ... in addon snake, open"), the terminal put back (`isig icanon iexten echo`, the alternate screen and the mouse modes left), the daemon keeping the shell as before; NOT BUILT, the user's to rule: recovery (an addon's panic ending its pane and not the session); the behaviour tests read the addons' ABI as 3.3; addon-test Debug whole
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'test')
| -rw-r--r-- | test/behaviour/addons.zig | 8 | ||||
| -rw-r--r-- | test/behaviour/addons_pdf.zig | 2 | ||||
| -rw-r--r-- | test/liar.zig | 1 | ||||
| -rw-r--r-- | test/veil.zig | 1 |
4 files changed, 7 insertions, 5 deletions
diff --git a/test/behaviour/addons.zig b/test/behaviour/addons.zig index e36b088c..1b284f8d 100644 --- a/test/behaviour/addons.zig +++ b/test/behaviour/addons.zig @@ -37,7 +37,7 @@ test "addons: Addon load takes a library in, /addons lists it with the kinds com defer unload(&s, "fake"); // `<kind> <version> <abi> <panes open> <path> <blake3> <state>`. const listed = try s.read("/addons"); - try std.testing.expect(std.mem.startsWith(u8, listed, "fake 1 3.2 0 /")); + try std.testing.expect(std.mem.startsWith(u8, listed, "fake 1 3.3 0 /")); var fields = std.mem.tokenizeScalar(u8, listed[0..std.mem.indexOfScalar(u8, listed, '\n').?], ' '); for (0..5) |_| _ = fields.next(); try std.testing.expectEqual(@as(usize, 64), fields.next().?.len); @@ -51,7 +51,7 @@ test "addons: Addon load takes a library in, /addons lists it with the kinds com // A pane of it open, it stays; closed, it goes. try s.write("/ctl", "Fake\n"); const pane = try paneOf(&s, "fake"); - try std.testing.expect(std.mem.startsWith(u8, try s.read("/addons"), "fake 1 3.2 1 /")); + try std.testing.expect(std.mem.startsWith(u8, try s.read("/addons"), "fake 1 3.3 1 /")); try std.testing.expect(try s.refused("/ctl", "Addon unload fake\n") != 0); try std.testing.expect(has(s.said, "1 fake pane is open")); try s.write(s.at("/pane/{d}/ctl", .{pane}), "Del\n"); @@ -68,7 +68,7 @@ test "addons: a library of another ABI, one with no pardes_addon, and one whose try std.testing.expect(std.mem.startsWith(u8, listed, "fakeabi 1 2.2 0 /")); try std.testing.expect(has(listed, " refused: wants abi 2, this pardes speaks 3\n")); try std.testing.expect(has(listed, " refused: it has no pardes_addon\n")); - try std.testing.expect(has(listed, "\nfakeword 1 3.2 0 /")); + try std.testing.expect(has(listed, "\nfakeword 1 3.3 0 /")); try std.testing.expect(has(listed, " refused: word Save is the core's\n")); // A file that is no library at all: listed with what the loader said. var tmp = std.testing.tmpDir(.{}); @@ -120,7 +120,7 @@ test "addons: the image addon opens the pictures a Look names, fitted, with the defer s.deinit(); try load(&s, Session.image_addon); const listed = try s.read("/addons"); - try std.testing.expect(std.mem.startsWith(u8, listed, "image 1 3.2 0 /") and has(listed, " loaded\n")); + try std.testing.expect(std.mem.startsWith(u8, listed, "image 1 3.3 0 /") and has(listed, " loaded\n")); var tmp = std.testing.tmpDir(.{}); defer tmp.cleanup(); var buf: [4096]u8 = undefined; diff --git a/test/behaviour/addons_pdf.zig b/test/behaviour/addons_pdf.zig index 18fa503c..0c7982d1 100644 --- a/test/behaviour/addons_pdf.zig +++ b/test/behaviour/addons_pdf.zig @@ -38,7 +38,7 @@ test "addons: a PDF is the pdf addon's pane, its pages pictures, its page in its s.graphics(); const n = try s.lookFile("docs/design.pdf"); try std.testing.expect(has(try s.read("/index"), " pdf ")); - try std.testing.expect(std.mem.startsWith(u8, try s.read("/addons"), "pdf 1 3.2 1 /")); + try std.testing.expect(std.mem.startsWith(u8, try s.read("/addons"), "pdf 1 3.3 1 /")); const pages = (try s.pdfPage(n))[1]; try std.testing.expectEqual(@as(u32, 16), pages); // Its first page, a picture over its body. diff --git a/test/liar.zig b/test/liar.zig index f564614b..e7bc2763 100644 --- a/test/liar.zig +++ b/test/liar.zig @@ -32,6 +32,7 @@ pub const Liar = extern struct { }; pub const pardes_addon = addon.ops(Liar); +pub const panic = addon.panic; comptime { addon.exportLib(&pardes_addon); } diff --git a/test/veil.zig b/test/veil.zig index 0be5d218..ac51de1c 100644 --- a/test/veil.zig +++ b/test/veil.zig @@ -32,6 +32,7 @@ pub const Veil = extern struct { }; pub const pardes_addon = addon.ops(Veil); +pub const panic = addon.panic; comptime { addon.exportLib(&pardes_addon); } |
