Re: Assertion failure on debug, what is wrong?

"Nicolas B. Pierron" <[email protected]> Mon, 29 Aug 2016 09:56:54 +0000
Newsgroups gmane.comp.mozilla.devel.jseng
Message-ID <[email protected]>
On 08/27/2016 09:06 AM, Mihai Dobrescu wrote:
> Assertion failure: stackRoots_[i] == nullptr
>
 > […]
 >
>          global = new JS::RootedObject(cx, JS_NewGlobalObject(cx, &global_class, nullptr, JS::FireOnNewGlobalHook));
>          if (!global)
>              return 1;

The problem might comes from here.

>
> What did I do wrong?


Rooted are meant to live on the stack. When the are constructed, they push 
they address into a linked list of rooted values. The assertion you got is 
likely coming from the pop-ing mechanism not working as a stack.

You should rewrite you code as follow:

     // no pointer, as this is already a pointer to a null global object.
     RootedGlobal global(cx);

     […]

     global = JS_NewGlobalObject(cx, &global_class, nullptr,
                                 JS::FireOnNewGlobalHook);
     if (!global)
         return 1;

-- 
Nicolas B. Pierron
_______________________________________________
dev-tech-js-engine mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine