diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2025-09-11 13:32:15 +0100 |
|---|---|---|
| committer | mlugg <mlugg@mlugg.co.uk> | 2025-09-30 13:44:53 +0100 |
| commit | 02a0ade138c035a7d45bd1ed26fe49dfec2942d2 (patch) | |
| tree | 6cfe8918c2ebf221f557249d639d074d00c29966 /lib/std/debug.zig | |
| parent | 4e45362529e05ba1be44fab48bc3469f5bb6492d (diff) | |
| download | zig-02a0ade138c035a7d45bd1ed26fe49dfec2942d2.tar.gz zig-02a0ade138c035a7d45bd1ed26fe49dfec2942d2.zip | |
std.debug: never attempt FP unwind under fomit-frame-pointer
Diffstat (limited to 'lib/std/debug.zig')
| -rw-r--r-- | lib/std/debug.zig | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/std/debug.zig b/lib/std/debug.zig index ae8ec072df..56769826b1 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -815,13 +815,17 @@ const StackIterator = union(enum) { /// On aarch64-macos, Apple mandate that the frame pointer is always used. /// TODO: are there any other architectures with guarantees like this? - const fp_unwind_is_safe = !builtin.omit_frame_pointer and builtin.cpu.arch == .aarch64 and builtin.os.tag.isDarwin(); + const fp_unwind_is_safe = builtin.cpu.arch == .aarch64 and builtin.os.tag.isDarwin(); /// Whether the current unwind strategy is allowed given `allow_unsafe`. fn stratOk(it: *const StackIterator, allow_unsafe: bool) bool { return switch (it.*) { .di => true, - .fp => allow_unsafe or fp_unwind_is_safe, + // If we omitted frame pointers from *this* compilation, FP unwinding would crash + // immediately regardless of anything. But FPs could also be omitted from a different + // linked object, so it's not guaranteed to be safe, unless the target specifically + // requires it. + .fp => !builtin.omit_frame_pointer and (fp_unwind_is_safe or allow_unsafe), }; } |
