Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libstd: fix off-by-one error in def of ProcSym in pdb.zig #12464

Merged
merged 1 commit into from Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/std/pdb.zig
Expand Up @@ -310,6 +310,10 @@ pub const SymbolKind = enum(u16) {

pub const TypeIndex = u32;

// TODO According to this header:
// https://github.com/microsoft/microsoft-pdb/blob/082c5290e5aff028ae84e43affa8be717aa7af73/include/cvinfo.h#L3722
// we should define RecordPrefix as part of the ProcSym structure.
// This might be important when we start generating PDB in self-hosted with our own PE linker.
pub const ProcSym = extern struct {
Parent: u32,
End: u32,
Expand All @@ -321,8 +325,7 @@ pub const ProcSym = extern struct {
CodeOffset: u32,
Segment: u16,
Flags: ProcSymFlags,
// following is a null terminated string
// Name: [*]u8,
Name: [1]u8, // null-terminated
};

pub const ProcSymFlags = packed struct {
Expand Down Expand Up @@ -693,7 +696,7 @@ pub const Pdb = struct {
.S_LPROC32, .S_GPROC32 => {
const proc_sym = @ptrCast(*align(1) ProcSym, &module.symbols[symbol_i + @sizeOf(RecordPrefix)]);
if (address >= proc_sym.CodeOffset and address < proc_sym.CodeOffset + proc_sym.CodeSize) {
return mem.sliceTo(@ptrCast([*:0]u8, proc_sym) + @sizeOf(ProcSym), 0);
return mem.sliceTo(@ptrCast([*:0]u8, &proc_sym.Name[0]), 0);
}
},
else => {},
Expand Down
7 changes: 1 addition & 6 deletions test/stack_traces.zig
Expand Up @@ -3,11 +3,6 @@ const os = std.os;
const tests = @import("tests.zig");

pub fn addCases(cases: *tests.StackTracesContext) void {
if (@import("builtin").os.tag == .windows) {
// https://github.com/ziglang/zig/issues/12422
return;
}

cases.addCase(.{
.name = "return",
.source =
Expand Down Expand Up @@ -178,7 +173,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
cases.addCase(.{
.exclude_os = .{
.openbsd, // integer overflow
.windows,
.windows, // TODO intermittent failures
},
.name = "dumpCurrentStackTrace",
.source =
Expand Down