Skip to content

Commit 3eb6c98

Browse files
committed
orte/odls: Fix ORTE state machine for the non-zero exit case
This commit fixes rare race condition that occurs when the process that is calling `exit(-1)` has delay between fd cleanup and actual OS-level exit. This may happen if the process has some work to do `on_exit()`. **Problem description**: Consider an application process that has called `exit(nonzero)`, it's fd's was closed but it's actual termination at OS level is delayed by some cleanups (eg. in callbacks registered via `on_exit()`). Observed sequence of events was the following: * orted gets stdio disconnection and activating `IOF COMPLETE` state. * parallel OOB disconnection causes `COMMUNICATION FAILURE` state to be activated. * during `COMMUNICATION FAILURE` processing `odls_base_default_wait_local_proc` is called even though real waitpid wasn't yet called (code mentions that waitpid might not be called for unspecified reason). Because of that real exit code is unknown and set to 0. `odls_base_default_wait_local_proc` callback sees `IOF COMPLETE` flag and in conjunction with 0-exit-code it activates `WAITPID FIRED` state. * processing of `WAITPID FIRED` leads to `NORMALLY TERMINATED` to be activated. * `NORMALLY TERMINATED` state in particular leads `ORTE_PROC_FLAG_ALIVE` flag for this proc to be dropped. * when application process finally exits and `wait_signal_callback` is launched. It sets real exit code and calls `odls_base_default_wait_local_proc` again but at this time since the process has `ORTE_PROC_FLAG_ALIVE` flag dropped `WAITPID FIRED` state is activated (instead of `EXITED WITH NON-ZERO`) leading to a hang that was observed. Signed-off-by: Artem Polyakov <[email protected]>
1 parent b343df4 commit 3eb6c98

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

orte/mca/odls/base/odls_base_default_fns.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* Copyright (c) 2013-2016 Intel, Inc. All rights reserved.
1818
* Copyright (c) 2014 Research Organization for Information Science
1919
* and Technology (RIST). All rights reserved.
20+
* Copyright (c) 2017 Mellanox Technologies Ltd. All rights reserved.
2021
* $COPYRIGHT$
2122
*
2223
* Additional copyrights may follow
@@ -1200,6 +1201,9 @@ void odls_base_default_wait_local_proc(orte_proc_t *proc, void* cbdata)
12001201
ORTE_NAME_PRINT(&proc->name),proc->exit_code));
12011202
if (WIFEXITED(proc->exit_code)) {
12021203
proc->exit_code = WEXITSTATUS(proc->exit_code);
1204+
if (0 != proc->exit_code) {
1205+
state = ORTE_PROC_STATE_TERM_NON_ZERO;
1206+
}
12031207
} else {
12041208
if (WIFSIGNALED(proc->exit_code)) {
12051209
state = ORTE_PROC_STATE_ABORTED_BY_SIG;

0 commit comments

Comments
 (0)