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.
// these ones use c deps, but if i move them out to platform... then core will have zero c dependencies.
// "lua",
"lua",
"spng",
// "nfd",
};

View File

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

View File

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

View File

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

View File

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

View File

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