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,13 +56,15 @@ pub const FailingAllocator = struct {
|
|||||||
return_address: usize,
|
return_address: usize,
|
||||||
) error{OutOfMemory}![]u8 {
|
) error{OutOfMemory}![]u8 {
|
||||||
if (self.index == self.fail_index) {
|
if (self.index == self.fail_index) {
|
||||||
mem.set(usize, &self.stack_addresses, 0);
|
if (!self.has_induced_failure) {
|
||||||
var stack_trace = std.builtin.StackTrace{
|
mem.set(usize, &self.stack_addresses, 0);
|
||||||
.instruction_addresses = &self.stack_addresses,
|
var stack_trace = std.builtin.StackTrace{
|
||||||
.index = 0,
|
.instruction_addresses = &self.stack_addresses,
|
||||||
};
|
.index = 0,
|
||||||
std.debug.captureStackTrace(return_address, &stack_trace);
|
};
|
||||||
self.has_induced_failure = true;
|
std.debug.captureStackTrace(return_address, &stack_trace);
|
||||||
|
self.has_induced_failure = true;
|
||||||
|
}
|
||||||
return error.OutOfMemory;
|
return error.OutOfMemory;
|
||||||
}
|
}
|
||||||
const result = try self.internal_allocator.rawAlloc(len, ptr_align, len_align, return_address);
|
const result = try self.internal_allocator.rawAlloc(len, ptr_align, len_align, return_address);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user