Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Getting a JS stack from an automation assertion

17 views
Skip to first unread message

Benjamin Smedberg

unread,
Jun 20, 2017, 1:54:09 PM6/20/17
to dev-platform
I'm working on a patch which adds a new assertion, and this code is failing
in automation in an intermittent way. The assertion is in C++ code but it's
being called by unknown JS code.

Is there a way to have automation call DumpJSStack() on assertion (before
crashing), or are there other debugging techniques using rr to get a JS
stack from the point of the assertion? Part of the problem with
reproduction is that the assertion only fires at browser shutdown, so
reproducing in a loop involves running an entire startup/shutdown cycle
which is quite slow.

Would it be safe to call DumpJSStack() explicitly from the place where I'm
firing this assertion, or are there potential issues with locking or the JS
engine internals that would make this a bad idea? (And would that output
show up in the automation logs?)

--BDS

Boris Zbarsky

unread,
Jun 20, 2017, 2:15:55 PM6/20/17
to
On 6/20/17 1:53 PM, Benjamin Smedberg wrote:
> Is there a way to have automation call DumpJSStack() on assertion (before
> crashing)

You could hack a DumpJSStack() call into the nsDebug machinery, basically.

> Would it be safe to call DumpJSStack() explicitly from the place where I'm
> firing this assertion, or are there potential issues with locking or the JS
> engine internals that would make this a bad idea? (And would that output
> show up in the automation logs?)

Calling DumpJSStack is generally safe, I believe, as long as you know
that you're on the main thread or a DOM worker thread. It'll crash on
you on other threads.

Given that you're dealing with shutdown, you need to make sue your call
happens before nsContentUtils::Shutdown, but hopefully that's the case
anyway if you know you're running JS.

One possible failure mode of DumpJSStack is that it will print nothing
if we're conceptually not running JS (e.g. have an AutoNoJSAPI on the
stack). You could work around that if you end up hitting it by
replacing the nsContentUtils::GetCurrentJSContextForThread() call in
xpc_DumpJSStack with mozilla::dom::danger::GetJSContext.

-Boris
0 new messages