Hello all:
I am working on a project where I need to print the JS stack trace when a
JS process becomes unresponsive. My approach involves setting a periodic
alarm using the `alarm()` function, and in the timeout function, I attempt
to print the JS stack trace.
I'm experiencing an issue where `v8::StackTrace::CurrentStackTrace` returns
a frame count of 0 when invoked within the signal handler. I understand
there could be some complications using the V8 API within a signal handler
due to its asynchronous signal-unsafe nature.
Here is a simplified version of my current approach:
// Assume isolate and context are correctly setup
void signalHandler(int signal) {
// Try to get stack trace and print
v8::HandleScope handleScope(isolate);
v8::Local<v8::StackTrace> stackTrace =
v8::StackTrace::CurrentStackTrace(
isolate,
10,
v8::StackTrace::kDetailed
);
int frameCount = stackTrace->GetFrameCount();
printf("Frame Count: %d\n", frameCount);
// Iterate and print each frame here...
}
int main() {
// Setup V8, isolate and context here...
signal(SIGALRM, signalHandler);
alarm(10); // Set alarm
// Rest of the program...
}
Is my approach flawed? Is there a safer or more effective method to achieve
what I'm trying to do?
Thanks
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups
"v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/v8-dev/0e06f5e3-b37b-4bcc-a293-65d152b0938fn%40googlegroups.com.