aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMason Remaley <mason@anthropicstudios.com>2025-02-26 14:53:14 -0800
committermlugg <mlugg@mlugg.co.uk>2025-04-02 05:54:04 +0100
commit87209954a74bbf9b82b7ab24c0389a4a133edd31 (patch)
tree6f940ec8607aa8a0ab9569b4c805ebacaf3d3801 /src
parent06ee383da9a23016dcb25ff7cb6811e3dc2c387e (diff)
downloadzig-87209954a74bbf9b82b7ab24c0389a4a133edd31.tar.gz
zig-87209954a74bbf9b82b7ab24c0389a4a133edd31.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/Zcu.zig2
-rw-r--r--src/Zcu/PerThread.zig1
2 files changed, 2 insertions, 1 deletions
diff --git a/src/Zcu.zig b/src/Zcu.zig
index 267551cb34..1486be6746 100644
--- a/src/Zcu.zig
+++ b/src/Zcu.zig
@@ -2753,7 +2753,7 @@ pub fn saveZoirCache(cache_file: std.fs.File, stat: std.fs.File.Stat, zoir: Zoir
},
.{
.base = @ptrCast(zoir.limbs),
- .len = zoir.limbs.len * 4,
+ .len = zoir.limbs.len * @sizeOf(std.math.big.Limb),
},
.{
.base = zoir.string_bytes.ptr,
diff --git a/src/Zcu/PerThread.zig b/src/Zcu/PerThread.zig
index 1031ee6c54..095cd6c1cb 100644
--- a/src/Zcu/PerThread.zig
+++ b/src/Zcu/PerThread.zig
@@ -234,6 +234,7 @@ pub fn updateFile(
error.FileTooBig => unreachable, // 0 is not too big
else => |e| return e,
};
+ try cache_file.seekTo(0);
if (stat.size > std.math.maxInt(u32))
return error.FileTooBig;