From: Andrii Grynenko Date: Wed, 8 Jun 2016 01:30:18 +0000 (-0700) Subject: Disable SIGSEGV signal handler if run in JVM X-Git-Tag: 2016.07.26~160 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=bbac9a999454bed7f7afce1958fda9150c9778e2;p=folly.git Disable SIGSEGV signal handler if run in JVM Reviewed By: ldemailly Differential Revision: D3402550 fbshipit-source-id: 3de47c569868545c3861dab9a7b244ed8fb1fadf --- diff --git a/folly/fibers/GuardPageAllocator.cpp b/folly/fibers/GuardPageAllocator.cpp index 87dc8f91..96595946 100644 --- a/folly/fibers/GuardPageAllocator.cpp +++ b/folly/fibers/GuardPageAllocator.cpp @@ -15,6 +15,9 @@ */ #include "GuardPageAllocator.h" +#ifndef _WIN32 +#include +#endif #include #include @@ -199,9 +202,20 @@ void sigsegvSignalHandler(int signum, siginfo_t* info, void*) { raise(signum); } +bool isInJVM() { + auto getCreated = dlsym(RTLD_DEFAULT, "JNI_GetCreatedJavaVMs"); + return getCreated; +} + void installSignalHandler() { static std::once_flag onceFlag; std::call_once(onceFlag, []() { + if (isInJVM()) { + // Don't install signal handler, since JVM internal signal handler doesn't + // work with SA_ONSTACK + return; + } + struct sigaction sa; memset(&sa, 0, sizeof(sa)); sigemptyset(&sa.sa_mask);