From 2d54f7ff16f353ec8267133a9159591fbeca9f8d Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 23 Nov 2026 17:58:08 -0300 Subject: 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 Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- addons/image/image.zig | 1 + addons/life/life.zig | 1 + addons/pdf/pdf.zig | 1 + addons/snake/snake.zig | 1 + addons/snake_shader/snake_shader.zig | 1 + 5 files changed, 5 insertions(+) (limited to 'addons') diff --git a/addons/image/image.zig b/addons/image/image.zig index 8e2cb32a..5b7976ac 100644 --- a/addons/image/image.zig +++ b/addons/image/image.zig @@ -128,6 +128,7 @@ pub const Image = extern struct { }; pub const pardes_addon = addon.ops(Image); +pub const panic = addon.panic; comptime { addon.exportLib(&pardes_addon); } diff --git a/addons/life/life.zig b/addons/life/life.zig index 254f248d..c49878cd 100644 --- a/addons/life/life.zig +++ b/addons/life/life.zig @@ -5,6 +5,7 @@ const std = @import("std"); const addon = @import("addon"); pub const pardes_addon = addon.ops(Life); +pub const panic = addon.panic; comptime { addon.exportLib(&pardes_addon); } diff --git a/addons/pdf/pdf.zig b/addons/pdf/pdf.zig index 5694e8c8..e1539eae 100644 --- a/addons/pdf/pdf.zig +++ b/addons/pdf/pdf.zig @@ -35,6 +35,7 @@ const m = @import("pdf_bridge"); const c = addon.c; pub const pardes_addon = addon.ops(Pdf); +pub const panic = addon.panic; comptime { addon.exportLib(&pardes_addon); } diff --git a/addons/snake/snake.zig b/addons/snake/snake.zig index ef2283ac..9f2bdd4e 100644 --- a/addons/snake/snake.zig +++ b/addons/snake/snake.zig @@ -131,6 +131,7 @@ pub const Snake = extern struct { }; pub const pardes_addon = addon.ops(Snake); +pub const panic = addon.panic; comptime { addon.exportLib(&pardes_addon); } diff --git a/addons/snake_shader/snake_shader.zig b/addons/snake_shader/snake_shader.zig index 039e07b0..65e1dd44 100644 --- a/addons/snake_shader/snake_shader.zig +++ b/addons/snake_shader/snake_shader.zig @@ -372,6 +372,7 @@ pub const Snake = extern struct { }; pub const pardes_addon = addon.ops(Snake); +pub const panic = addon.panic; comptime { addon.exportLib(&pardes_addon); } -- cgit v1.3