Skip to content

Commit b023448

Browse files
hjelmnSergey Oblomov
authored andcommitted
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]> (cherry picked from commit d8916a4) Signed-off-by: Nathan Hjelm <[email protected]>
1 parent 32e190a commit b023448

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

opal/mca/btl/ugni/btl_ugni_frag.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ static inline int mca_btl_ugni_frag_return (mca_btl_ugni_base_frag_t *frag)
188188

189189
static inline bool mca_btl_ugni_frag_del_ref (mca_btl_ugni_base_frag_t *frag, int rc) {
190190
mca_btl_ugni_module_t *ugni_module = mca_btl_ugni_ep_btl (frag->endpoint);
191+
/* save the descriptor flags since the callback is allowed to free the frag */
192+
int des_flags = frag->base.des_flags;
191193
int32_t ref_cnt;
192194

193195
opal_atomic_mb ();
@@ -199,11 +201,11 @@ static inline bool mca_btl_ugni_frag_del_ref (mca_btl_ugni_base_frag_t *frag, in
199201
}
200202

201203
/* call callback if specified */
202-
if (frag->base.des_flags & MCA_BTL_DES_SEND_ALWAYS_CALLBACK) {
204+
if (des_flags & MCA_BTL_DES_SEND_ALWAYS_CALLBACK) {
203205
frag->base.des_cbfunc(&ugni_module->super, frag->endpoint, &frag->base, rc);
204206
}
205207

206-
if (frag->base.des_flags & MCA_BTL_DES_FLAGS_BTL_OWNERSHIP) {
208+
if (des_flags & MCA_BTL_DES_FLAGS_BTL_OWNERSHIP) {
207209
mca_btl_ugni_frag_return (frag);
208210
}
209211

0 commit comments

Comments
 (0)