aboutsummaryrefslogtreecommitdiff
path: root/lib/std/debug/Dwarf.zig
diff options
context:
space:
mode:
authorAlec Fessler <afessler1998@gmail.com>2025-02-22 15:07:44 -0500
committerAndrew Kelley <andrew@ziglang.org>2025-02-24 04:36:14 -0500
commit1cc388d5263058f9e9eecc410eea825a9a58e143 (patch)
tree90a02eaeeb263bd175a9525fd27e16d8eb269acb /lib/std/debug/Dwarf.zig
parentecc76348e6858f00b920d8dc9e44a6e703d8e497 (diff)
downloadzig-1cc388d5263058f9e9eecc410eea825a9a58e143.tar.gz
zig-1cc388d5263058f9e9eecc410eea825a9a58e143.zip
stdlib: handle EEXIST in mmap with FIXED_NOREPLACE. Fixes #21475
Diffstat (limited to 'lib/std/debug/Dwarf.zig')
-rw-r--r--lib/std/debug/Dwarf.zig7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/std/debug/Dwarf.zig b/lib/std/debug/Dwarf.zig
index b72ddcac47..e5d47ba491 100644
--- a/lib/std/debug/Dwarf.zig
+++ b/lib/std/debug/Dwarf.zig
@@ -2434,14 +2434,17 @@ pub const ElfModule = struct {
const end_pos = elf_file.getEndPos() catch return bad();
const file_len = cast(usize, end_pos) orelse return error.Overflow;
- const mapped_mem = try std.posix.mmap(
+ const mapped_mem = std.posix.mmap(
null,
file_len,
std.posix.PROT.READ,
.{ .TYPE = .SHARED },
elf_file.handle,
0,
- );
+ ) catch |err| switch (err) {
+ error.MappingAlreadyExists => unreachable,
+ else => |e| return e,
+ };
errdefer std.posix.munmap(mapped_mem);
return load(