Skip to content

Segfault - new ELF linker - debug #25786

@mike-git374

Description

@mike-git374

Zig Version

0.16.0-dev.1204+389368392

Steps to Reproduce and Observed Behavior

const std = @import("std");

pub fn main() !void {
   var d: std.heap.DebugAllocator(.{}) = .init;
   _ = try d.allocator().alloc(u8, 1);
}
zig build-exe -fnew-linker main.zig
./main
Segmentation fault at address 0x208fc0
aborting due to recursive panic

Executable from New linker gets a Segfault on this line 5074:

zig/lib/std/posix.zig

Lines 5071 to 5074 in 2f4bca4

const elf_base = std.process.getBaseAddress();
const ehdr: *elf.Ehdr = @ptrFromInt(elf_base);
// Make sure the base address points to an ELF image.
assert(mem.eql(u8, ehdr.e_ident[0..4], elf.MAGIC));

Old linker works fine: zig build-exe -fno-new-linker main.zig

This may be related to other issues like
#25328
#25421

Expected Behavior

No segfault

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorstandard libraryThis issue involves writing Zig code for the standard library.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions