From d17d0d9649ae47b383325020eb147b80e5ce75b3 Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Fri, 12 Jul 2024 11:08:15 +0200 Subject: Store newly spliced executables as copies. During multithreaded splicing, the main process can be forked (inheriting open file descriptors). In this case, the executable file saved using hardlinking becomes inaccessible. To prevent this, executables must be stored as copies made in a child process. (cherry-picked from a336b835ee0831ba5fe2f4e8f9b1773eff68416b) --- src/buildtool/storage/local_cas.tpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/buildtool/storage/local_cas.tpp b/src/buildtool/storage/local_cas.tpp index 02c007d5..6a406b5f 100644 --- a/src/buildtool/storage/local_cas.tpp +++ b/src/buildtool/storage/local_cas.tpp @@ -321,8 +321,16 @@ requires(kIsLocalGeneration) auto LocalCAS::LocalUplinkBlob( } // Uplink blob from older generation to the latest generation. - return blob_path_latest.has_value() or - latest.StoreBlob(*blob_path, is_executable); + if (spliced and is_executable) { + // During multithreaded splicing, the main process can be forked + // (inheriting open file descriptors). In this case, an executable file + // saved using hardlinking becomes inaccessible. To prevent this, + // executables must be stored as copies made in a child process. + return latest.StoreBlob(*blob_path, is_executable) + .has_value(); + } + return latest.StoreBlob(*blob_path, is_executable) + .has_value(); } template -- cgit v1.2.3