Skip to content
DebugFreedEntry

DebugFreedEntry

Description

Bounded-history record for a successfully-freed allocation. Kept in the freed Vec ring; scanned linearly when the next free can’t find a live record, to emit the original alloc + first-free traces alongside Heap’s double-free abort.

Usage example (Cross-references)

Usage examples (Cross-references)
            StackFrame alloc_trace[DEBUG_ALLOCATOR_MAX_TRACE];
            StackFrame free_trace[DEBUG_ALLOCATOR_MAX_TRACE];
        } DebugFreedEntry;
    
        typedef Vec(DebugFreedEntry) DebugFreedVec;
        } DebugFreedEntry;
    
        typedef Vec(DebugFreedEntry) DebugFreedVec;
    
        ///
    // want the bookkeeping cost.
    
    static const DebugFreedEntry *debug_freed_find(const DebugAllocator *dbg, void *ptr) {
        for (u32 i = 0; i < VecLen(&dbg->freed); i++) {
            if (VecPtrAt(&dbg->freed, i)->ptr == ptr)
            // them, then abort -- the freed-history hit is conclusive
            // evidence of a double-free.
            const DebugFreedEntry *fe = debug_freed_find(self, ptr);
            if (fe) {
                LOG_ERROR(
        // call site. Unbounded; gated by track_freed_history config.
        if (self->config.track_freed_history) {
            DebugFreedEntry entry;
            entry.ptr            = ptr;
            entry.requested_size = live_rec->requested_size;
        ok = ok && (DebugAllocatorFreedCount(&dbg) == 1);
    
        const DebugFreedEntry *fe    = VecPtrAt(&dbg.freed, 0);
        bool                   match = ok;
        for (u32 i = 0; ok && i < n; i++) {
Last updated on