From bbac9a999454bed7f7afce1958fda9150c9778e2 Mon Sep 17 00:00:00 2001 From: Andrii Grynenko Date: Tue, 7 Jun 2016 18:30:18 -0700 Subject: [PATCH] Disable SIGSEGV signal handler if run in JVM Reviewed By: ldemailly Differential Revision: D3402550 fbshipit-source-id: 3de47c569868545c3861dab9a7b244ed8fb1fadf --- folly/fibers/GuardPageAllocator.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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); -- 2.34.1