diff --git a/src/bthread/task_group.cpp b/src/bthread/task_group.cpp index 579bb23120..c421d2f241 100644 --- a/src/bthread/task_group.cpp +++ b/src/bthread/task_group.cpp @@ -635,6 +635,10 @@ int TaskGroup::join(bthread_t tid, void** return_value) { return errno; } } + // Ensure all memory writes made by the joined bthread are visible to + // the joining thread after join returns. This matches the semantic + // guarantee provided by pthread_join() across supported architectures. + butil::atomic_thread_fence(butil::memory_order_acquire); if (return_value) { *return_value = NULL; }