Compare commits

...

5 commits

Author SHA1 Message Date
0a4c1a57b1
build: update std/debug.zig to zig-0.15.0-dev.877+0adcfd60f 2025-07-01 19:48:48 +02:00
b258b2bb54
Merge branch 'master' into zig-0.15.0 2025-07-01 19:44:56 +02:00
10476f4e87
fix: add back missing windows check for crash handler 2025-07-01 18:02:34 +02:00
24730f90c0
build: update thespian to avoid SIGTRAP triggering the debugger 2025-07-01 17:36:17 +02:00
21551795ad
feat: install signal crash handler to reset terminal before dumping stack traces
This currently requires cloning std.debug to grant access to the standard trace
dump handler. Hopefully in future this could be made public in the standard
library.
2025-07-01 17:34:41 +02:00
4 changed files with 1776 additions and 3 deletions

View file

@ -15,8 +15,8 @@
.hash = "dizzy-1.0.0-AAAAAM1wAAAiDbx_6RwcVEOBk8p2XOu8t9WPNc3K7kBK", .hash = "dizzy-1.0.0-AAAAAM1wAAAiDbx_6RwcVEOBk8p2XOu8t9WPNc3K7kBK",
}, },
.thespian = .{ .thespian = .{
.url = "https://github.com/neurocyte/thespian/archive/a7b2354ad2fbe9d2b3629a455f2e823b463c18eb.tar.gz", .url = "https://github.com/neurocyte/thespian/archive/829a8d33e92988a51a8c51d204ec766a28c7903d.tar.gz",
.hash = "thespian-0.0.1-owFOjosTBgAgvY4TcT_xI30QsbU8cE_tAUu_HoxoTjMV", .hash = "thespian-0.0.1-owFOjs0TBgAAed7EtHDPtpB7NBn-riNjb7Rkc7a_Voow",
}, },
.themes = .{ .themes = .{
.url = "https://github.com/neurocyte/flow-themes/releases/download/master-952f9f630ea9544088fd30293666ee0650b7a690/flow-themes.tar.gz", .url = "https://github.com/neurocyte/flow-themes/releases/download/master-952f9f630ea9544088fd30293666ee0650b7a690/flow-themes.tar.gz",

View file

@ -149,7 +149,10 @@ pub fn main() anyerror!void {
} }
if (builtin.os.tag != .windows) if (builtin.os.tag != .windows)
if (std.posix.getenv("JITDEBUG")) |_| thespian.install_debugger(); if (std.posix.getenv("JITDEBUG")) |_|
thespian.install_debugger()
else if (@hasDecl(renderer, "install_crash_handler"))
renderer.install_crash_handler();
if (args.debug_wait) { if (args.debug_wait) {
std.debug.print("press return to start", .{}); std.debug.print("press return to start", .{});

View file

@ -118,6 +118,34 @@ pub fn panic_in_progress() bool {
return in_panic.load(.acquire); return in_panic.load(.acquire);
} }
pub fn install_crash_handler() void {
if (!std.debug.have_segfault_handling_support) {
@compileError("segfault handler not supported for this target");
}
const act = std.posix.Sigaction{
.handler = .{ .sigaction = handle_crash },
.mask = std.posix.sigemptyset(),
.flags = (std.posix.SA.SIGINFO | std.posix.SA.RESTART),
};
std.posix.sigaction(std.posix.SIG.BUS, &act, null);
std.posix.sigaction(std.posix.SIG.SEGV, &act, null);
std.posix.sigaction(std.posix.SIG.ABRT, &act, null);
std.posix.sigaction(std.posix.SIG.FPE, &act, null);
std.posix.sigaction(std.posix.SIG.ILL, &act, null);
}
fn handle_crash(sig: i32, info: *const std.posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.c) noreturn {
in_panic.store(true, .release);
const cleanup = panic_cleanup;
panic_cleanup = null;
if (cleanup) |self| {
self.vx.deinit(self.allocator, self.tty.anyWriter());
self.tty.deinit();
}
@import("std/debug.zig").handleSegfaultPosix(sig, info, ctx_ptr);
}
pub fn run(self: *Self) Error!void { pub fn run(self: *Self) Error!void {
self.vx.sgr = .legacy; self.vx.sgr = .legacy;
self.vx.conpty_hacks = true; self.vx.conpty_hacks = true;

File diff suppressed because it is too large Load diff