1
0
Fork 0
mirror of https://github.com/rubyjs/therubyracer synced 2023-03-27 23:21:42 -04:00
therubyracer/ext/v8/v8_exception.cpp

24 lines
517 B
C++
Raw Normal View History

#include "v8_exception.h"
#include "rr.h"
#include "execinfo.h"
#include "signal.h"
namespace {
static void* stack[20];
void fatal(const char* location, const char* message) {
rb_raise(rb_eFatal, "%s: %s", location, message);
}
void segfault(int sig) {
fprintf(stderr, "segfault: game over.\n");
int size = backtrace(stack, 20);
backtrace_symbols_fd(stack, size, 2);
exit(1);
}
}
void rr_init_v8_exception() {
v8::V8::SetFatalErrorHandler(fatal);
signal(SIGSEGV, segfault);
}