From 93377e99e2ffa260f1da5b53326d51ef19ab74f6 Mon Sep 17 00:00:00 2001 From: Ryan Prichard Date: Tue, 19 Sep 2023 21:04:39 -0700 Subject: [PATCH 1/3] snapuserd_test: don't discard result of std::async std::async returns a std::future whose destructor blocks until the async function has completed, which defeats the purpose of using std::async. The future needs to be kept alive to allow the function to run concurrently. Starting in C++20, std::async marked [[nodiscard]] to help catch this misuse. Upgrading libc++ adds the [[nodiscard]] attribute to std::async, so fixing this bug is necessary to keep the code compiling after libc++ is updated. Bug: 175635923 Test: treehugger Test: m && m snapuserd_test Change-Id: Id2e820248c2b6111aa843fb709e08a2c19677066 --- .../snapuserd/user-space-merge/snapuserd_test.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_test.cpp b/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_test.cpp index 01fe06fe7..620ecbd3f 100644 --- a/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_test.cpp +++ b/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_test.cpp @@ -714,10 +714,12 @@ TEST_F(SnapuserdTest, Snapshot_MERGE_IO_TEST) { } ASSERT_NO_FATAL_FAILURE(SetupDefault()); // Issue I/O before merge begins - std::async(std::launch::async, &SnapuserdTest::ReadSnapshotDeviceAndValidate, this); + auto read_future = + std::async(std::launch::async, &SnapuserdTest::ReadSnapshotDeviceAndValidate, this); // Start the merge ASSERT_TRUE(Merge()); ValidateMerge(); + read_future.wait(); } TEST_F(SnapuserdTest, Snapshot_MERGE_IO_TEST_1) { @@ -728,9 +730,11 @@ TEST_F(SnapuserdTest, Snapshot_MERGE_IO_TEST_1) { // Start the merge ASSERT_TRUE(StartMerge()); // Issue I/O in parallel when merge is in-progress - std::async(std::launch::async, &SnapuserdTest::ReadSnapshotDeviceAndValidate, this); + auto read_future = + std::async(std::launch::async, &SnapuserdTest::ReadSnapshotDeviceAndValidate, this); CheckMergeCompletion(); ValidateMerge(); + read_future.wait(); } TEST_F(SnapuserdTest, Snapshot_Merge_Resume) { From 999efbef093214bf8302591a17a777439a0a85e6 Mon Sep 17 00:00:00 2001 From: Ryan Prichard Date: Thu, 21 Sep 2023 17:51:52 -0700 Subject: [PATCH 2/3] Add missing and includes Bug: 175635923 Test: m MODULES-IN-system-core-libutils Change-Id: I065907a58a88723ae512f155dfde2d2fcb3fc322 --- libutils/String16_fuzz.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libutils/String16_fuzz.cpp b/libutils/String16_fuzz.cpp index a271aeebd..8f9781bfe 100644 --- a/libutils/String16_fuzz.cpp +++ b/libutils/String16_fuzz.cpp @@ -13,7 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include #include +#include #include "fuzzer/FuzzedDataProvider.h" #include "utils/String16.h" From 87c90e7b65c734ba553a4655d0aee8c7dd939676 Mon Sep 17 00:00:00 2001 From: Ryan Prichard Date: Thu, 21 Sep 2023 19:44:47 -0700 Subject: [PATCH 3/3] Add missing include Bug: 175635923 Test: m MODULES-IN-system-core-trusty Change-Id: I7790dde8eba948cf95cb14dd2b436c3f6f88765a --- trusty/apploader/apploader.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/trusty/apploader/apploader.cpp b/trusty/apploader/apploader.cpp index 17d083c73..f782d2acb 100644 --- a/trusty/apploader/apploader.cpp +++ b/trusty/apploader/apploader.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include