From b3c63e5de0c0441b9facc71b4c7e0a3d1811368d Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Thu, 6 Feb 2025 10:44:01 +0100 Subject: [PATCH] Dwarf: fix cross_section_relocs capacity This ensure capacity call does not match the number of appendAssumeCapacity() calls that follow it. Fix this. This was discovered due to hitting the assertion failure in appendAssumeCapacity() while building river. I'm not sure how to isolate a minimal reproducer for a test. --- src/link/Dwarf.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/link/Dwarf.zig b/src/link/Dwarf.zig index 6f596b61618a4383d0ed3627a26867f269976f15..19a310dd63aa825d425c8de98738e4f64b5c157a 100644 --- a/src/link/Dwarf.zig +++ b/src/link/Dwarf.zig @@ -4576,7 +4576,7 @@ pub fn flushModule(dwarf: *Dwarf, pt: Zcu.PerThread) FlushError!void { ); for (dwarf.mods.values(), dwarf.debug_line.section.units.items) |mod_info, *unit| { unit.clear(); - try unit.cross_section_relocs.ensureTotalCapacity(dwarf.gpa, 2 * (1 + mod_info.files.count())); + try unit.cross_section_relocs.ensureTotalCapacity(dwarf.gpa, mod_info.dirs.count() + 2 * (mod_info.files.count())); header.clearRetainingCapacity(); try header.ensureTotalCapacity(unit.header_len); const unit_len = (if (unit.next.unwrap()) |next_unit| -- 2.54.0