mirror of
https://github.com/ziglang/zig.git
synced 2025-12-16 11:13:08 +00:00
FailingAllocator: Only capture the stack trace of the first induced allocation failure
This is a precaution to avoid confusing stack traces on the off chance that FailingAllocator continues to try to allocate after the first failure.
This commit is contained in:
parent
c321b2f2a0
commit
19d7f4dd82
@ -56,6 +56,7 @@ pub const FailingAllocator = struct {
|
||||
return_address: usize,
|
||||
) error{OutOfMemory}![]u8 {
|
||||
if (self.index == self.fail_index) {
|
||||
if (!self.has_induced_failure) {
|
||||
mem.set(usize, &self.stack_addresses, 0);
|
||||
var stack_trace = std.builtin.StackTrace{
|
||||
.instruction_addresses = &self.stack_addresses,
|
||||
@ -63,6 +64,7 @@ pub const FailingAllocator = struct {
|
||||
};
|
||||
std.debug.captureStackTrace(return_address, &stack_trace);
|
||||
self.has_induced_failure = true;
|
||||
}
|
||||
return error.OutOfMemory;
|
||||
}
|
||||
const result = try self.internal_allocator.rawAlloc(len, ptr_align, len_align, return_address);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user