restored minidumps

This commit is contained in:
peterino2 2025-10-22 21:00:54 -07:00
parent 02dff11242
commit e119dac3e1
6 changed files with 43 additions and 42 deletions

View File

@ -7,7 +7,7 @@ const dependencyList = [_][]const u8{
"packer", // packer might need to be split into another setup that doesn't have C deps. "packer", // packer might need to be split into another setup that doesn't have C deps.
// these ones use c deps, but if i move them out to platform... then core will have zero c dependencies. // these ones use c deps, but if i move them out to platform... then core will have zero c dependencies.
// "lua", "lua",
"spng", "spng",
// "nfd", // "nfd",
}; };

View File

@ -12,6 +12,7 @@
.zmath = .{ .path = "../../lib/zmath" }, .zmath = .{ .path = "../../lib/zmath" },
.packer = .{ .path = "../../lib/packer" }, .packer = .{ .path = "../../lib/packer" },
.p2 = .{ .path = "../../lib/p2" }, .p2 = .{ .path = "../../lib/p2" },
.lua = .{ .path = "../../lib/lua" },
// .zgltf = .{ .path = "../../lib/zgltf" }, // .zgltf = .{ .path = "../../lib/zgltf" },
}, },
.paths = .{ .paths = .{

View File

@ -216,7 +216,7 @@ pub const undefineComponentList = ecs.undefineComponentList;
pub const Entity = ecs.Entity; pub const Entity = ecs.Entity;
pub const createEntity = ecs.createEntity; pub const createEntity = ecs.createEntity;
// pub const script = @import("script.zig"); pub const script = @import("script.zig");
pub const stacks = @import("stacks.zig"); pub const stacks = @import("stacks.zig");
pub const walkAndPrintStack = stacks.walkAndPrintStack; pub const walkAndPrintStack = stacks.walkAndPrintStack;
@ -294,7 +294,7 @@ pub fn start_module_(map: *SpecVariantMap, args: anytype, allocator: std.mem.All
fatDump = true; fatDump = true;
} }
// script.lua.setupMiniDump(fatDump); script.lua.setupMiniDump(fatDump);
_ = try algorithm.createNameRegistry(allocator); _ = try algorithm.createNameRegistry(allocator);
// LUA BEGIN -- what if i want to make the scripting integration optional? // LUA BEGIN -- what if i want to make the scripting integration optional?
// try script.start_lua(allocator); // try script.start_lua(allocator);

View File

@ -32,49 +32,48 @@ fn waitForOtherThreadToFinishPanicking() void {
} }
} }
fn handleSegfaultWindowsExtra( fn handleSegfaultWindowsExtra(info: *windows.EXCEPTION_POINTERS, msg: u8, label: ?[]const u8) noreturn {
info: *windows.EXCEPTION_POINTERS, // For backends that cannot handle the language features used by this segfault handler, we have a simpler one,
msg: u8, switch (builtin.zig_backend) {
label: ?[]const u8, .stage2_x86_64 => if (builtin.target.ofmt == .coff) @trap(),
) noreturn { else => {},
const exception_address = @intFromPtr(info.ExceptionRecord.ExceptionAddress); }
core.engine_logs("PANIC!!");
core.logging.forceFlush(); core.logging.forceFlush();
if (!@hasDecl(windows, "CONTEXT")) { comptime std.debug.assert(windows.CONTEXT != void);
switch (msg) { nosuspend switch (panic_stage) {
0 => { 0 => {
dumpSegfaultInfoWindows(info, msg, label); panic_stage = 1;
std.posix.abort(); _ = panicking.fetchAdd(1, .seq_cst);
{
const stderr = std.debug.lockStderrWriter(&.{});
defer std.debug.unlockStderrWriter();
dumpSegfaultInfoWindows(info, msg, label, stderr);
}
waitForOtherThreadToFinishPanicking();
}, },
1 => { 1 => {
const format_item = "Segmentation fault at address 0x{x}"; panic_stage = 2;
var buf: [format_item.len + 64]u8 = undefined; // 64 is arbitrary, but sufficiently large std.fs.File.stderr().writeAll("aborting due to recursive panic\n") catch {};
const to_print = std.fmt.bufPrint(buf[0..buf.len], format_item, .{info.ExceptionRecord.ExceptionInformation[1]}) catch unreachable;
std.debug.panicImpl(null, exception_address, to_print);
}, },
2 => std.debug.panicImpl(null, exception_address, "Illegal Instruction"), else => {},
else => unreachable, };
}
} else {
dumpSegfaultInfoWindows(info, msg, label);
std.posix.abort(); std.posix.abort();
}
} }
fn dumpSegfaultInfoWindows(info: *windows.EXCEPTION_POINTERS, msg: u8, label: ?[]const u8) void { fn dumpSegfaultInfoWindows(info: *windows.EXCEPTION_POINTERS, msg: u8, label: ?[]const u8, stderr: *std.io.Writer) void {
var segfaultBuffer: [4096]u8 = undefined;
var stderr = std.fs.File.stderr().writer(&segfaultBuffer);
_ = switch (msg) { _ = switch (msg) {
0 => stderr.interface.print("{s}\n", .{label.?}), 0 => stderr.print("{s}\n", .{label.?}),
1 => stderr.interface.print("Segmentation fault at address 0x{x}\n", .{info.ExceptionRecord.ExceptionInformation[1]}), 1 => stderr.print("Segmentation fault at address 0x{x}\n", .{info.ExceptionRecord.ExceptionInformation[1]}),
2 => stderr.interface.print("Illegal instruction at address 0x{x}\n", .{info.ContextRecord.getRegs().ip}), 2 => stderr.print("Illegal instruction at address 0x{x}\n", .{info.ContextRecord.getRegs().ip}),
else => unreachable, else => unreachable,
} catch std.posix.abort(); } catch std.posix.abort();
std.debug.dumpStackTraceFromBase(info.ContextRecord, &stderr.interface); std.debug.dumpStackTraceFromBase(info.ContextRecord, stderr);
} }
pub fn dumpStackPointerAddr(prefix: []const u8) void { pub fn dumpStackPointerAddr(prefix: []const u8) void {

View File

@ -33,7 +33,7 @@ pub fn main() !void {
var iterations: u32 = 0; var iterations: u32 = 0;
var BUFFER: [8192]u8 = undefined; var BUFFER: [8192]u8 = undefined;
while (iterations < 32) : (iterations += 1) { while (iterations < 8) : (iterations += 1) {
if (fileExists("content") or fileExists("content.pak")) { if (fileExists("content") or fileExists("content.pak")) {
break; break;
} }
@ -46,7 +46,7 @@ pub fn main() !void {
core.engine_log("Working Dir set: {s}", .{try std.fs.cwd().realpath(".", &BUFFER)}); core.engine_log("Working Dir set: {s}", .{try std.fs.cwd().realpath(".", &BUFFER)});
} }
// panickers.attachSegfaultHandler(); panickers.attachSegfaultHandler();
try realMain.main(); try realMain.main();
} }

View File

@ -236,10 +236,11 @@ pub const PhysicsRuntime = struct {
// self.system.update(0.01, .{}) catch {}; // self.system.update(0.01, .{}) catch {};
{ {
const interface = self.system.getBodyInterfaceMut(); const interface = self.system.getBodyInterfaceMut();
_ = interface;
var iterator = self.idToEntity.keyIterator(); var iterator = self.idToEntity.keyIterator();
while (iterator.next()) |bodyId| { while (iterator.next()) |bodyId| {
interface.removeAndDestroyBody(bodyId.*); _ = bodyId;
// interface.removeAndDestroyBody(bodyId.*);
} }
} }