Skip to content

Commit d8916a4

Browse files
committed
btl/ugni: fix race condition in completing frags
The descriptor flags field in a fragment were being ready after the fragment may have been freed. This commit reads the flags before calling the user callback. Signed-off-by: Nathan Hjelm <[email protected]>
1 parent 87d41da commit d8916a4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

opal/mca/btl/ugni/btl_ugni_frag.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ static inline int mca_btl_ugni_frag_return (mca_btl_ugni_base_frag_t *frag)
227227

228228
static inline bool mca_btl_ugni_frag_del_ref (mca_btl_ugni_base_frag_t *frag, int rc) {
229229
mca_btl_ugni_module_t *ugni_module = mca_btl_ugni_ep_btl (frag->endpoint);
230+
/* save the descriptor flags since the callback is allowed to free the frag */
231+
int des_flags = frag->base.des_flags;
230232
int32_t ref_cnt;
231233

232234
opal_atomic_mb ();
@@ -238,11 +240,11 @@ static inline bool mca_btl_ugni_frag_del_ref (mca_btl_ugni_base_frag_t *frag, in
238240
}
239241

240242
/* call callback if specified */
241-
if (frag->base.des_flags & MCA_BTL_DES_SEND_ALWAYS_CALLBACK) {
243+
if (des_flags & MCA_BTL_DES_SEND_ALWAYS_CALLBACK) {
242244
frag->base.des_cbfunc(&ugni_module->super, frag->endpoint, &frag->base, rc);
243245
}
244246

245-
if (frag->base.des_flags & MCA_BTL_DES_FLAGS_BTL_OWNERSHIP) {
247+
if (des_flags & MCA_BTL_DES_FLAGS_BTL_OWNERSHIP) {
246248
mca_btl_ugni_frag_return (frag);
247249
}
248250

0 commit comments

Comments
 (0)