From 048bcc1604a7e8aca666e219c0fdc3cd5517029e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 2 Jun 2023 06:10:34 +0200 Subject: Fix data race in library metadata protocol logic --- libbuild2/cc/common.cxx | 5 +++-- libbuild2/cc/windows-rpath.cxx | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'libbuild2/cc') diff --git a/libbuild2/cc/common.cxx b/libbuild2/cc/common.cxx index c423c37..07a4d48 100644 --- a/libbuild2/cc/common.cxx +++ b/libbuild2/cc/common.cxx @@ -382,9 +382,10 @@ namespace build2 for (const prerequisite_target& pt: l.prerequisite_targets[a]) { // Note: adhoc prerequisites are not part of the library metadata - // protocol (and we should check for adhoc first to avoid races). + // protocol (and we should check for adhoc first to avoid races + // during execute). // - if (pt == nullptr || pt.adhoc ()) + if (pt.adhoc () || pt == nullptr) continue; if (marked (pt)) diff --git a/libbuild2/cc/windows-rpath.cxx b/libbuild2/cc/windows-rpath.cxx index 9387078..bd5a928 100644 --- a/libbuild2/cc/windows-rpath.cxx +++ b/libbuild2/cc/windows-rpath.cxx @@ -128,7 +128,9 @@ namespace build2 library_cache lib_cache; for (const prerequisite_target& pt: t.prerequisite_targets[a]) { - if (pt == nullptr || pt.adhoc ()) + // Note: during execute so check for ad hoc first to avoid data races. + // + if (pt.adhoc () || pt == nullptr) continue; bool la; @@ -255,7 +257,9 @@ namespace build2 library_cache lib_cache; for (const prerequisite_target& pt: t.prerequisite_targets[a]) { - if (pt == nullptr || pt.adhoc ()) + // Note: during execute so check for ad hoc first to avoid data races. + // + if (pt.adhoc () || pt == nullptr) continue; bool la; -- cgit v1.1