Skip to content

stack trace code tries to access invalid memory #24970

@andrewrk

Description

@andrewrk

In master branch this is protected by MemoryAccessor, but I'm about to delete that.

Thread 1 received signal SIGSEGV, Segmentation fault.
0x00000000015c45f4 in debug.StackIterator.next_internal (it=0x7fbdd0825150) at debug.zig:949
warning: Source file is more recent than executable.
949             const new_fp = math.add(usize, @as(*usize, @ptrFromInt(fp)).*, fp_bias) catch
(gdb) p/x fp
$1 = 0x2caf0b8900000000
(gdb) bt
#0  0x00000000015c45f4 in debug.StackIterator.next_internal (it=0x7fbdd0825150) at debug.zig:949
#1  0x00000000015c06f8 in debug.StackIterator.next (it=0x7fbdd0825150) at debug.zig:876
#2  0x00000000016304e0 in debug.captureStackTrace (first_address=..., stack_trace=0x7fbdd0825480)
    at debug.zig:506
#3  0x0000000001633d44 in heap.debug_allocator.DebugAllocator(.{ .stack_trace_frames = 10, .enable_memory_limit = false, .safety = true, .thread_safe = true, .MutexType = null, .never_unmap = false, .retain_metadata = false, .verbose_log = false, .backing_allocator_zeroes = true, .resize_stack_traces = true, .canary = 2824291834806075834, .page_size = 262144 }).collectStackTrace (first_trace_addr=23064936, addresses=0x7fbdc2f77720)
    at /home/andy/src/zig/lib/std/heap/debug_allocator.zig:515
#4  0x000000000162ebb0 in heap.debug_allocator.DebugAllocator(.{ .stack_trace_frames = 10, .enable_memory_limit = false, .safety = true, .thread_safe = true, .MutexType = null, .never_unmap = false, .retain_metadata = false, .verbose_log = false, .backing_allocator_zeroes = true, .resize_stack_traces = true, .canary = 2824291834806075834, .page_size = 262144 }).BucketHeader.captureStackTrace (bucket=0x7fbdc2f771f0, ret_addr=23064936, 
    slot_count=220, slot_index=445, trace_kind=alloc)
    at /home/andy/src/zig/lib/std/heap/debug_allocator.zig:333
#5  0x0000000001629ecc in heap.debug_allocator.DebugAllocator(.{ .stack_trace_frames = 10, .enable_memory_limit = false, .safety = true, .thread_safe = true, .MutexType = null, .never_unmap = false, .retain_metadata = false, .verbose_log = false, .backing_allocator_zeroes = true, .resize_stack_traces = true, .canary = 2824291834806075834, .page_size = 262144 }).alloc (context=0x2bab6e8 <testing.allocator_instance>, len=516, 
    alignment=4, ret_addr=23064936) at /home/andy/src/zig/lib/std/heap/debug_allocator.zig:764
#6  0x00000000016105d0 in mem.Allocator.rawAlloc () at /home/andy/src/zig/lib/std/mem/Allocator.zig:129
#7  mem.Allocator.allocBytesWithAlignment__anon_17076 (self=..., byte_count=516, return_address=23064936)
    at /home/andy/src/zig/lib/std/mem/Allocator.zig:283
#8  0x000000000160d22c in mem.Allocator.allocWithSizeAndAlignment__anon_16965 (self=..., n=516, 
    return_address=23064936) at /home/andy/src/zig/lib/std/mem/Allocator.zig:269
#9  0x0000000001606710 in mem.Allocator.allocAdvancedWithRetAddr ()
    at /home/andy/src/zig/lib/std/mem/Allocator.zig:257
#10 mem.Allocator.alignedAlloc__anon_16749 (self=..., n=516)
    at /home/andy/src/zig/lib/std/mem/Allocator.zig:245
#11 0x00000000015ff168 in array_hash_map.IndexHeader.alloc (gpa=..., new_bit_index=8 '\b')
    at array_hash_map.zig:2150
#12 0x0000000001681354 in array_hash_map.ArrayHashMapUnmanaged(i32,i32,array_hash_map.AutoContext(i32),false).ensureTotalCapacityContext (self=0x7fbdd0826590, gpa=..., new_capacity=77) at array_hash_map.zig:897
#13 0x0000000001680a10 in array_hash_map.ArrayHashMapUnmanaged(i32,i32,array_hash_map.AutoContext(i32),false).getOrPutContextAdapted__anon_40359 (self=0x7fbdd0826590, gpa=..., key=76) at array_hash_map.zig:787
#14 0x000000000167e60c in array_hash_map.ArrayHashMapUnmanaged(i32,i32,array_hash_map.AutoContext(i32),false).getOrPutContext (self=0x7fbdd0826590, gpa=<error reading variable: value has been optimized out>, key=76)
    at array_hash_map.zig:775
#15 0x000000000167e1dc in array_hash_map.ArrayHashMapUnmanaged(i32,i32,array_hash_map.AutoContext(i32),false).fetchPutContext (self=0x7fbdd0826590, gpa=<error reading variable: value has been optimized out>, key=76, 
    value=760) at array_hash_map.zig:993
#16 0x000000000167e118 in array_hash_map.ArrayHashMapWithAllocator(i32,i32,array_hash_map.AutoContext(i32),false).fetchPut (self=0x7fbdd0826590, key=76, value=760) at array_hash_map.zig:286
#17 0x000000000169095c in array_hash_map.test.shrink () at array_hash_map.zig:2420
#18 0x000000000162c458 in test_runner.mainTerminal () at /home/andy/src/zig/lib/compiler/test_runner.zig:218
#19 0x00000000016260e8 in test_runner.main () at /home/andy/src/zig/lib/compiler/test_runner.zig:66
#20 0x00000000016254fc in start.callMain () at start.zig:618
#21 start.callMainWithArgs () at start.zig:587
#22 start.posixCallMainAndExit (argc_argv_ptr=0x7fbdd0826ea0) at start.zig:542
#23 0x0000000000000000 in ?? ()
(gdb) 

Metadata

Metadata

Assignees

No one assigned

    Labels

    arch-powerpc32-bit and 64-bit Power ISAbugObserved behavior contradicts documented or intended behaviorregressionIt worked in a previous version of Zig, but stopped working.standard libraryThis issue involves writing Zig code for the standard library.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions