authorgravatar for mason@anthropicstudios.comMason Remaley <mason@anthropicstudios.com> 2025-02-26 14:53:14-08:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-04-02 14:21:51+02:00
log40891348923e48cbf371db5227acea7bb8b263aa
treeb5662b660284ad3f420cfea3c17fc77d9bd9599b
parentf2c838d2cf652b7124ef60af1e7fdc5601b51fe1
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

Zcu: fix ZOIR cache bugs

* When saving bigint limbs, we gave the iovec the wrong length, meaning bigint data (and the following string and compile error data) was corrupted. * When updating a stale ZOIR cache, we failed to truncate the file, so just wrote more bytes onto the end of the stale cache.

2 files changed, 2 insertions(+), 1 deletions(-)

src/Zcu.zig+1-1
......@@ -2751,7 +2751,7 @@ pub fn saveZoirCache(cache_file: std.fs.File, stat: std.fs.File.Stat, zoir: Zoir
27512751 },
27522752 .{
27532753 .base = @ptrCast(zoir.limbs),
2754 .len = zoir.limbs.len * 4,
2754 .len = zoir.limbs.len * @sizeOf(std.math.big.Limb),
27552755 },
27562756 .{
27572757 .base = zoir.string_bytes.ptr,
src/Zcu/PerThread.zig+1
......@@ -234,6 +234,7 @@ pub fn updateFile(
234234 error.FileTooBig => unreachable, // 0 is not too big
235235 else => |e| return e,
236236 };
237 try cache_file.seekTo(0);
237238
238239 if (stat.size > std.math.maxInt(u32))
239240 return error.FileTooBig;