Skip to content

Commit 0be55df

Browse files
committed
osc/rdma: Fix segfault in shared memory peer initialization
Commit 815fe8e changed ompi_osc_rdma_peer_local_base() calls to ompi_osc_rdma_peer_cpu_atomics() in accumulate operations. This caused local peers without CPU atomics to fall back to network operations, but their base_handle was not initialized, leading to a NULL pointer dereference in the BTL layer. Fix by setting base_handle for local peers when use_memory_registration is enabled (indicating BTL requires registered memory handles for RDMA operations) and use_cpu_atomics is false (forcing network fallback). Signed-off-by: Shi Jin <[email protected]>
1 parent 333d8ad commit 0be55df

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

ompi/mca/osc/rdma/osc_rdma_component.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* Copyright (c) 2015-2017 Intel, Inc. All rights reserved.
1919
* Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
2020
* Copyright (c) 2018 Cisco Systems, Inc. All rights reserved
21-
* Copyright (c) 2018-2022 Amazon.com, Inc. or its affiliates.
21+
* Copyright (c) 2018-2025 Amazon.com, Inc. or its affiliates.
2222
* All Rights reserved.
2323
* Copyright (c) 2019 Research Organization for Information Science
2424
* and Technology (RIST). All rights reserved.
@@ -867,6 +867,16 @@ static int allocate_state_shared (ompi_osc_rdma_module_t *module, void **base, s
867867
if (use_cpu_atomics) {
868868
peer->flags |= OMPI_OSC_RDMA_PEER_CPU_ATOMICS;
869869
}
870+
871+
/* set base_handle for local peers when memory registration is used */
872+
if (module->use_memory_registration && !use_cpu_atomics) {
873+
if (MPI_WIN_FLAVOR_ALLOCATE == module->flavor) {
874+
ex_peer->super.base_handle = module->state_handle;
875+
} else {
876+
ex_peer->super.base_handle = module->base_handle;
877+
}
878+
}
879+
870880
offset += temp[i].size;
871881
offset += OPAL_ALIGN_PAD_AMOUNT(offset, memory_alignment);
872882
} else {

0 commit comments

Comments
 (0)