Skip to content

Commit ed5aeab

Browse files
rmacnak-googleCommit Queue
authored andcommitted
[test] Fix data race in samples/ffi/async/async_test.
TEST=tsan Bug: #55615 Change-Id: I4de5701037640f5b0ae6b176f695907c4c5e1ef5 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365209 Commit-Queue: Daco Harkes <[email protected]> Reviewed-by: Daco Harkes <[email protected]>
1 parent 25a309a commit ed5aeab

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

runtime/bin/ffi_test/ffi_test_functions_vmspecific.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,9 +480,10 @@ intptr_t MyCallbackBlocking(intptr_t a) {
480480
auto callback = my_callback_blocking_fp_; // Define storage duration.
481481
std::condition_variable cv;
482482
bool notified = false;
483-
const Work work = [a, &result, callback, &cv, &notified]() {
483+
const Work work = [a, &result, callback, &mutex, &cv, &notified]() {
484484
result = callback(a);
485485
printf("C Da: Notify result ready.\n");
486+
std::unique_lock<std::mutex> lock(mutex);
486487
notified = true;
487488
cv.notify_one();
488489
};

0 commit comments

Comments
 (0)