Commit bbac9a99 authored by Andrii Grynenko's avatar Andrii Grynenko Committed by Facebook Github Bot 5

Disable SIGSEGV signal handler if run in JVM

Reviewed By: ldemailly

Differential Revision: D3402550

fbshipit-source-id: 3de47c569868545c3861dab9a7b244ed8fb1fadf
parent 6da900e4
......@@ -15,6 +15,9 @@
*/
#include "GuardPageAllocator.h"
#ifndef _WIN32
#include <dlfcn.h>
#endif
#include <signal.h>
#include <mutex>
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment