From d0f675827c28b1d50e8aea6a7d29cb45ad8d4e67 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 1 Mar 2023 22:55:47 -0700 Subject: [PATCH] link: only write manifest if we have the exclusive lock Fixes assertion tripping when racing multiple processes that will create the same static archive. --- src/link.zig | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/link.zig b/src/link.zig index a2f40eed65..96931dd79e 100644 --- a/src/link.zig +++ b/src/link.zig @@ -1078,9 +1078,11 @@ pub const File = struct { log.warn("failed to save archive hash digest file: {s}", .{@errorName(err)}); }; - man.writeManifest() catch |err| { - log.warn("failed to write cache manifest when archiving: {s}", .{@errorName(err)}); - }; + if (man.have_exclusive_lock) { + man.writeManifest() catch |err| { + log.warn("failed to write cache manifest when archiving: {s}", .{@errorName(err)}); + }; + } base.lock = man.toOwnedLock(); }