Skip to content

Commit

Permalink
prov/shm: fix shm multi recv setopt segfault
Browse files Browse the repository at this point in the history
shm uses the util srx and sets the minimum multi receive size through
the srx. However, the srx code doesn't get initialized until the endpoint
gets enabled. So if the application calls setopt (before FI_ENABLE), this
will segfault because the srx has not been initialized. Instead, we need
to save the multi recv size in the shm endpoint to be valid during setopt
and then pass that into the util_srx creation to set the multi recv size

Signed-off-by: Alexia Ingerson <[email protected]>
  • Loading branch information
aingerson committed Dec 9, 2024
1 parent 7953ad7 commit 2c53734
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions prov/shm/src/smr.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ struct smr_ep {
struct smr_tx_fs *tx_fs;
struct dlist_entry sar_list;
struct dlist_entry ipc_cpy_pend_list;
size_t min_multi_recv_size;

int ep_idx;
enum ofi_shm_p2p_type p2p_type;
Expand Down
7 changes: 4 additions & 3 deletions prov/shm/src/smr_ep.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ int smr_ep_setopt(fid_t fid, int level, int optname, const void *optval,
return -FI_ENOPROTOOPT;

if (optname == FI_OPT_MIN_MULTI_RECV) {
srx = smr_ep->srx->ep_fid.fid.context;
srx->min_multi_recv_size = *(size_t *)optval;
smr_ep->min_multi_recv_size = *(size_t *)optval;
return FI_SUCCESS;
}

Expand Down Expand Up @@ -1146,7 +1145,7 @@ static int smr_ep_ctrl(struct fid *fid, int command, void *arg)
util_domain.domain_fid);
ret = util_ep_srx_context(&domain->util_domain,
ep->rx_size, SMR_IOV_LIMIT,
SMR_INJECT_SIZE, &smr_update,
ep->min_multi_recv_size, &smr_update,
&ep->util_ep.lock, &srx);
if (ret)
return ret;
Expand Down Expand Up @@ -1308,6 +1307,8 @@ int smr_endpoint(struct fid_domain *domain, struct fi_info *info,
dlist_init(&ep->sar_list);
dlist_init(&ep->ipc_cpy_pend_list);

ep->min_multi_recv_size = SMR_INJECT_SIZE;

ep->util_ep.ep_fid.fid.ops = &smr_ep_fi_ops;
ep->util_ep.ep_fid.ops = &smr_ep_ops;
ep->util_ep.ep_fid.cm = &smr_cm_ops;
Expand Down

0 comments on commit 2c53734

Please sign in to comment.