Skip to content

Commit

Permalink
Dwarf: fix cross_section_relocs capacity
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ifreund committed Feb 7, 2025
1 parent bf7bc4f commit b3c63e5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/link/Dwarf.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down

0 comments on commit b3c63e5

Please sign in to comment.