Last year I worked with members of the V8 team to add low-overhead debug
information to V8 so that we could debug Node.js programs postmortem.[1] This
information has proven quite valuable, and we've configured our Node programs to
invoke abort(3C) (via Node's process.abort()) whenever we get the
"uncaughtException" event. We've nailed several nasty production issues based
on the resulting core files without having to reproduce the problem. See [2]
for a particularly nasty example.
That said, there's one problem with this approach: by the time we get to the
uncaughtException handler, all of the stack state associated with the exception
is gone. If we blow an assertion or trip over an undefined variable inside a
function, it's often valuable to know what the arguments to that function were,
but that's all gone by the time the event is emitted. My proposal is to add a
command line flag that causes V8 to call OS::Abort when an uncaught exception is
emitted. The diffs are pretty small:
but the result is that we get a core file with the current JavaScript stack
intact, including arguments. This particular change helped us nail two
instances of RangeError (see [3] for my write-up of one of them).
If the team is okay with this change, I'd like to submit a code review and have
it integrated into V8.
Thanks,
Dave