summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-23 17:58:08 -0300
committerGabriel Schneider <[email protected]>2026-11-23 18:05:08 -0300
commit2d54f7ff16f353ec8267133a9159591fbeca9f8d (patch)
treece5c00e973ad49f18cbd6183efa5f3662ce4b41c /core
parent4eb608b0c1f231005237b0f57283d22bfccee0a9 (diff)
downloadpardes-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 'core')
-rw-r--r--core/Kind.zig11
1 files changed, 10 insertions, 1 deletions
diff --git a/core/Kind.zig b/core/Kind.zig
index 5d2dcdb0..764b6f06 100644
--- a/core/Kind.zig
+++ b/core/Kind.zig
@@ -41,7 +41,7 @@ comptime {
if (@sizeOf(usize) == 8) for (.{
.{ c.pa_cell, 20 }, .{ c.pa_window, 24 }, .{ c.pa_rect, 16 }, .{ c.pa_cells, 8 },
.{ c.pa_placement, 80 }, .{ c.pa_paint, 48 }, .{ c.pa_key, 8 }, .{ c.pa_mouse, 16 },
- .{ c.pa_api, 120 }, .{ c.pa_out, 16 }, .{ c.pa_word, 32 }, .{ c.pa_head, 56 },
+ .{ c.pa_api, 128 }, .{ c.pa_out, 16 }, .{ c.pa_word, 32 }, .{ c.pa_head, 56 },
.{ c.pa_ops, 208 }, .{ c.pa_view, 32 }, .{ c.pa_tick, 128 },
}) |r| if (@sizeOf(r[0]) != r[1]) @compileError(std.fmt.comptimePrint("{s} is {d} bytes, the header says {d}", .{ @typeName(r[0]), @sizeOf(r[0]), r[1] }));
}
@@ -1229,6 +1229,15 @@ pub const api: c.pa_api = .{
return token;
}
}.f,
+ .panic = struct {
+ /// An addon's panic is pardes's (its root's handler: the crash
+ /// record, the terminal, the clients): a call into it never returns.
+ fn f(msg: [*c]const u8, n: u32) callconv(.c) void {
+ var buf: [512]u8 = undefined;
+ const said = cSlice(msg, n);
+ @panic(std.fmt.bufPrint(&buf, "an addon's panic: {s}", .{said}) catch said);
+ }
+ }.f,
.found = struct {
/// Gathered in the call: the search's answer, or onto its +Search after.
fn f(rows: [*c]const u8, n: u32) callconv(.c) void {