Skip to content

Commit 75a42af

Browse files
committed
Continuations: Fix potential race condition in debug mode
The cont->cont_req field was reset *after* it was returned to the freelist... Signed-off-by: Joseph Schuchart <[email protected]>
1 parent e366ae0 commit 75a42af

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

ompi/mpiext/continue/c/continuation.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,13 @@ void ompi_continue_cont_release(ompi_continuation_t *cont, int rc)
277277
OBJ_RELEASE(cont_req);
278278

279279
if (OMPI_SUCCESS == rc) {
280-
opal_free_list_return(&ompi_continuation_freelist, &cont->super);
281280
#ifdef OPAL_ENABLE_DEBUG
282281
cont->cont_cb = NULL;
283282
cont->cont_data = NULL;
284283
cont->cont_req = NULL;
284+
opal_atomic_wmb();
285285
#endif // OPAL_ENABLE_DEBUG
286+
opal_free_list_return(&ompi_continuation_freelist, &cont->super);
286287
}
287288
}
288289

@@ -888,6 +889,8 @@ int ompi_continue_attach(
888889

889890
req_cont_data->cont_obj = cont;
890891

892+
opal_atomic_wmb();
893+
891894
ompi_request_set_callback(request, &request_completion_cb, req_cont_data);
892895
++num_registered;
893896

@@ -1065,6 +1068,7 @@ int ompi_continue_get_failed(
10651068
cont->cont_cb = NULL;
10661069
cont->cont_data = NULL;
10671070
cont->cont_req = NULL;
1071+
opal_atomic_wmb();
10681072
#endif // OPAL_ENABLE_DEBUG
10691073
opal_free_list_return(&ompi_continuation_freelist, &cont->super);
10701074
}

0 commit comments

Comments
 (0)