Skip to content

Commit

Permalink
Avoid adding SegfaultLogger if process already has sig handler. (apac…
Browse files Browse the repository at this point in the history
…he#13842)

In current implemenation, we override signal handler regardless if MXNET_USE_SIGNAL_HANDLER=1.
This breaks caller process behavior and cause process exit unexpectedly.
The example use case is libmxnet.so is loadded into java process via JNI or JNA. JVM will crash
due to SegfaultLogger.

In this PR, we will not register SegfaultLogger if there is a signal handler registered.
  • Loading branch information
frankfliu authored and haohuw committed Jun 23, 2019
1 parent edeb3ca commit 4e19bb8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/initialize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ class LibraryInitializer {
LibraryInitializer() {
dmlc::InitLogging("mxnet");
#if MXNET_USE_SIGNAL_HANDLER && DMLC_LOG_STACK_TRACE
signal(SIGSEGV, SegfaultLogger);
struct sigaction sa;
sigaction(SIGSEGV, NULL, &sa);
if (sa.sa_handler == NULL) {
signal(SIGSEGV, SegfaultLogger);
}
#endif

// disable openmp for multithreaded workers
Expand Down

0 comments on commit 4e19bb8

Please sign in to comment.