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 zachgk committed May 15, 2019
1 parent 1428ada commit d13b47b
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 d13b47b

Please sign in to comment.