Skip to content
This repository was archived by the owner on Sep 30, 2022. It is now read-only.

Commit d2a185e

Browse files
committed
oob/usock: fix handling of orte_process_name_t *
orte_process_name_t is aligned on 32 bits, so it cannot simply be casted into an int64_t. use memcpy() instead Thanks Paul Hargrove for the report (back-ported from commit open-mpi/ompi@0b8c582)
1 parent edb35d5 commit d2a185e

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

orte/mca/oob/usock/oob_usock.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* Copyright (c) 2009-2015 Cisco Systems, Inc. All rights reserved.
1515
* Copyright (c) 2011 Oak Ridge National Labs. All rights reserved.
1616
* Copyright (c) 2013-2016 Intel, Inc. All rights reserved.
17+
* Copyright (c) 2016 Research Organization for Information Science
18+
* and Technology (RIST). All rights reserved.
1719
* $COPYRIGHT$
1820
*
1921
* Additional copyrights may follow
@@ -366,7 +368,7 @@ static void recv_handler(int sd, short flags, void *cbdata)
366368
mca_oob_usock_conn_op_t *op = (mca_oob_usock_conn_op_t*)cbdata;
367369
mca_oob_usock_hdr_t hdr;
368370
mca_oob_usock_peer_t *peer;
369-
uint64_t *ui64;
371+
uint64_t ui64;
370372

371373
opal_output_verbose(OOB_USOCK_DEBUG_CONNECT, orte_oob_base_framework.framework_output,
372374
"%s:usock:recv:handler called",
@@ -406,8 +408,8 @@ static void recv_handler(int sd, short flags, void *cbdata)
406408
peer->state);
407409
}
408410
CLOSE_THE_SOCKET(sd);
409-
ui64 = (uint64_t*)(&peer->name);
410-
opal_hash_table_set_value_uint64(&mca_oob_usock_module.peers, (*ui64), NULL);
411+
memcpy(&ui64, &peer->name, sizeof(uint64_t));
412+
opal_hash_table_set_value_uint64(&mca_oob_usock_module.peers, ui64, NULL);
411413
OBJ_RELEASE(peer);
412414
}
413415
}

orte/mca/oob/usock/oob_usock_component.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* Copyright (c) 2009-2013 Cisco Systems, Inc. All rights reserved.
1616
* Copyright (c) 2011 Oak Ridge National Labs. All rights reserved.
1717
* Copyright (c) 2013-2015 Intel, Inc. All rights reserved.
18+
* Copyright (c) 2016 Research Organization for Information Science
19+
* and Technology (RIST). All rights reserved.
1820
* $COPYRIGHT$
1921
*
2022
* Additional copyrights may follow
@@ -305,21 +307,21 @@ static int component_set_addr(orte_process_name_t *peer,
305307
{
306308
orte_proc_t *proc;
307309
mca_oob_usock_peer_t *pr;
308-
uint64_t *ui64;
310+
uint64_t ui64;
309311

312+
memcpy(&ui64, peer, sizeof(uint64_t));
310313
/* if I am an application, then everything is addressable
311314
* by me via my daemon
312315
*/
313316
if (ORTE_PROC_IS_APP) {
314317
/* if this is my daemon, then take it - otherwise, ignore */
315318
if (ORTE_PROC_MY_DAEMON->jobid == peer->jobid &&
316319
ORTE_PROC_MY_DAEMON->vpid == peer->vpid) {
317-
ui64 = (uint64_t*)peer;
318320
if (OPAL_SUCCESS != opal_hash_table_get_value_uint64(&mca_oob_usock_module.peers,
319-
(*ui64), (void**)&pr) || NULL == pr) {
321+
ui64, (void**)&pr) || NULL == pr) {
320322
pr = OBJ_NEW(mca_oob_usock_peer_t);
321323
pr->name = *peer;
322-
opal_hash_table_set_value_uint64(&mca_oob_usock_module.peers, (*ui64), pr);
324+
opal_hash_table_set_value_uint64(&mca_oob_usock_module.peers, ui64, pr);
323325
}
324326
/* we have to initiate the connection because otherwise the
325327
* daemon has no way to communicate to us via this component
@@ -344,12 +346,11 @@ static int component_set_addr(orte_process_name_t *peer,
344346
return ORTE_ERR_TAKE_NEXT_OPTION;
345347
}
346348
/* indicate that this peer is addressable by this component */
347-
ui64 = (uint64_t*)peer;
348349
if (OPAL_SUCCESS != opal_hash_table_get_value_uint64(&mca_oob_usock_module.peers,
349-
(*ui64), (void**)&pr) || NULL == pr) {
350+
ui64, (void**)&pr) || NULL == pr) {
350351
pr = OBJ_NEW(mca_oob_usock_peer_t);
351352
pr->name = *peer;
352-
opal_hash_table_set_value_uint64(&mca_oob_usock_module.peers, (*ui64), pr);
353+
opal_hash_table_set_value_uint64(&mca_oob_usock_module.peers, ui64, pr);
353354
}
354355
return ORTE_SUCCESS;
355356
}

orte/mca/oob/usock/oob_usock_connection.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ int mca_oob_usock_peer_recv_connect_ack(mca_oob_usock_peer_t* pr, int sd,
513513
size_t credsize;
514514
mca_oob_usock_peer_t *peer;
515515
mca_oob_usock_hdr_t hdr;
516-
uint64_t *ui64;
516+
uint64_t ui64;
517517

518518
opal_output_verbose(OOB_USOCK_DEBUG_CONNECT, orte_oob_base_framework.framework_output,
519519
"%s RECV CONNECT ACK FROM %s ON SOCKET %d",
@@ -588,8 +588,8 @@ int mca_oob_usock_peer_recv_connect_ack(mca_oob_usock_peer_t* pr, int sd,
588588
peer->name = hdr.origin;
589589
peer->state = MCA_OOB_USOCK_ACCEPTING;
590590
peer->sd = sd;
591-
ui64 = (uint64_t*)(&peer->name);
592-
if (OPAL_SUCCESS != opal_hash_table_set_value_uint64(&mca_oob_usock_module.peers, (*ui64), peer)) {
591+
memcpy(&ui64, &peer->name, sizeof(uint64_t));
592+
if (OPAL_SUCCESS != opal_hash_table_set_value_uint64(&mca_oob_usock_module.peers, ui64, peer)) {
593593
OBJ_RELEASE(peer);
594594
CLOSE_THE_SOCKET(sd);
595595
return ORTE_ERR_UNREACH;

0 commit comments

Comments
 (0)