summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2024-07-12 11:08:15 +0200
committerMaksim Denisov <denisov.maksim@huawei.com>2024-07-12 12:29:17 +0200
commita336b835ee0831ba5fe2f4e8f9b1773eff68416b (patch)
treecd93d67eb9e39430392ea2578ab1480b9345373f /src
parent718c294145d1c4b080e13b42705b374ae9c7b3a5 (diff)
downloadjustbuild-a336b835ee0831ba5fe2f4e8f9b1773eff68416b.tar.gz
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.
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/storage/local_cas.tpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/buildtool/storage/local_cas.tpp b/src/buildtool/storage/local_cas.tpp
index e0cb3883..97ecf1a3 100644
--- a/src/buildtool/storage/local_cas.tpp
+++ b/src/buildtool/storage/local_cas.tpp
@@ -78,8 +78,16 @@ requires(kIsLocalGeneration) auto LocalCAS<kDoGlobalUplink>::LocalUplinkBlob(
}
// Uplink blob from older generation to the latest generation.
- return blob_path_latest.has_value() or
- latest.StoreBlob</*kOwner=*/true>(*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</*kOwner=*/false>(*blob_path, is_executable)
+ .has_value();
+ }
+ return latest.StoreBlob</*kOwner=*/true>(*blob_path, is_executable)
+ .has_value();
}
template <bool kDoGlobalUplink>