mirror of
https://github.com/ziglang/zig.git
synced 2026-12-05 16:58:53 -05:00
gpa: Fix GeneralPurposeAllocator double free stack traces
The wrong `size_class` was used when fetching stack traces from empty buckets. The `size_class` would always be the maximum value after exhausting the search of active buckets rather than the actual `size_class` of the allocation.
This commit is contained in:
1 parent
61f1b2db70
commit
762e2a4b52
1 file changed
+2
@@ -732,6 +732,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
|
||||
if (!self.large_allocations.contains(@intFromPtr(old_mem.ptr))) {
|
||||
// object not in active buckets or a large allocation, so search empty buckets
|
||||
if (searchBucket(&self.empty_buckets, @intFromPtr(old_mem.ptr), null)) |bucket| {
|
||||
size_class = bucket.emptyBucketSizeClass();
|
||||
// bucket is empty so is_used below will always be false and we exit there
|
||||
break :blk bucket;
|
||||
} else {
|
||||
@@ -850,6 +851,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
|
||||
if (!self.large_allocations.contains(@intFromPtr(old_mem.ptr))) {
|
||||
// object not in active buckets or a large allocation, so search empty buckets
|
||||
if (searchBucket(&self.empty_buckets, @intFromPtr(old_mem.ptr), null)) |bucket| {
|
||||
size_class = bucket.emptyBucketSizeClass();
|
||||
// bucket is empty so is_used below will always be false and we exit there
|
||||
break :blk bucket;
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user