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)
    // want the bookkeeping cost.
    
    static const DebugFreedEntry *debug_freed_find(const DebugAllocator *dbg, void *ptr) {
        for (u32 i = 0; i < dbg->freed.length; i++) {
            if (dbg->freed.data[i].ptr == ptr)
            // them, then abort -- the freed-history hit is conclusive
            // evidence of a double-free.
            const DebugFreedEntry *fe = debug_freed_find(dbg, ptr);
            if (fe) {
                LOG_ERROR(
        // call site. Unbounded; gated by track_freed_history config.
        if (dbg->config.track_freed_history) {
            DebugFreedEntry entry;
            entry.ptr            = ptr;
            entry.requested_size = live_rec->requested_size;
            StackFrame alloc_trace[DEBUG_ALLOCATOR_MAX_TRACE];
            StackFrame free_trace[DEBUG_ALLOCATOR_MAX_TRACE];
        } DebugFreedEntry;
    
        typedef Vec(DebugFreedEntry) DebugFreedVec;
        } DebugFreedEntry;
    
        typedef Vec(DebugFreedEntry) DebugFreedVec;
    
        ///
Last updated on