Skip to documentation
SLOP

tiny.deadalloc.RepairTable

Reference tiny.deadalloc RepairTable

Defined in tiny.deadalloc.

API (7)

Actions

Public operations.

Fields and members

Public fields and members.

No direct callersNo direct callstiny.deadallocRepairTable
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: lib/deadalloc/src/exterminator.zig:17

zig
pub const RepairTable = struct {    overflow_count: usize = 0,    dangle_count: usize = 0,    overflow_entries: [max_repair_entries]OverflowRepair = @as([max_repair_entries]OverflowRepair, @splat(.{})),    dangle_entries: [max_repair_entries]DangleRepair = @as([max_repair_entries]DangleRepair, @splat(.{})),    pub fn fromReport(report: report_mod.Report, current: RepairTable) RepairTable {        var next = current;        for (report.issueSlice()) |issue| next.recordIssue(issue);        return next;    }    pub fn overflowPadding(self: RepairTable, allocation_return_address: usize) usize {        var index: usize = 0;        while (index < self.overflow_count) : (index += 1) {            const entry = self.overflow_entries[index];            if (entry.allocation_return_address == allocation_return_address) return entry.padding_bytes;        }        return 0;    }    pub fn lifeExtension(self: RepairTable, allocation_return_address: usize, free_return_address: usize) u64 {        var index: usize = 0;        while (index < self.dangle_count) : (index += 1) {            const entry = self.dangle_entries[index];            if (entry.allocation_return_address == allocation_return_address and entry.free_return_address == free_return_address) {                return entry.quarantine_epochs;            }        }        return 0;    }    fn recordIssue(self: *RepairTable, issue: report_mod.Issue) void {        switch (issue.kind) {            .buffer_overflow => self.recordOverflow(issue),            .use_after_free, .double_free => self.recordDangle(issue),            .invalid_free, .leak, .size_mismatch => {},        }    }    fn recordOverflow(self: *RepairTable, issue: report_mod.Issue) void {        if (issue.allocation_return_address == 0) return;        const needed = if (issue.offset >= issue.requested_len)            issue.offset - issue.requested_len + 1        else            1;        if (needed == 0) return;        var index: usize = 0;        while (index < self.overflow_count) : (index += 1) {            if (self.overflow_entries[index].allocation_return_address == issue.allocation_return_address) {                self.overflow_entries[index].padding_bytes = @max(self.overflow_entries[index].padding_bytes, needed);                return;            }        }        if (self.overflow_count == self.overflow_entries.len) return;        self.overflow_entries[self.overflow_count] = .{            .allocation_return_address = issue.allocation_return_address,            .padding_bytes = needed,        };        self.overflow_count += 1;    }    fn recordDangle(self: *RepairTable, issue: report_mod.Issue) void {        if (issue.allocation_return_address == 0) return;        const free_return_address = if (issue.free_return_address != 0) issue.free_return_address else issue.return_address;        if (free_return_address == 0) return;        var index: usize = 0;        while (index < self.dangle_count) : (index += 1) {            if (self.dangle_entries[index].allocation_return_address == issue.allocation_return_address and self.dangle_entries[index].free_return_address == free_return_address) {                self.dangle_entries[index].quarantine_epochs = growU64(self.dangle_entries[index].quarantine_epochs, 1, 4096);                return;            }        }        if (self.dangle_count == self.dangle_entries.len) return;        self.dangle_entries[self.dangle_count] = .{            .allocation_return_address = issue.allocation_return_address,            .free_return_address = free_return_address,            .quarantine_epochs = 1,        };        self.dangle_count += 1;    }};

Source: lib/deadalloc/src/root.zig:54

zig
pub const RepairTable = exterminator_mod.RepairTable;
Called byCallsNo direct callstest sourcelib.deadalloc.src.allocatortest: repair config applies dangle ex...RepairPolicyfromReporttest sourcelib.deadalloc.src.exterminatortest: repair table records dangle ext...test sourcelib.deadalloc.src.exterminatortest: repair table records overflow p...RepairTablefromReport
Static calls · unresolved targets: 0 · external targets: 2.
Called byCallsNo direct callsprivate sourcelib.deadalloc.src.allocator.ConfigrepairQuarantineEpochsRepairTablelifeExtension
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsprivate sourcelib.deadalloc.src.allocator.ConfigrepairPaddingRepairTableoverflowPadding
Static calls · unresolved targets: 0 · external targets: 0.

Audit

Definitions4
Public names4
Members4
Version26.7.0
Revisiondaab053ee433