0

I'm embedding SpiderMonkey in an iOS app and am getting assertion failures when doing JS_GC and JS_MaybeGC. It happens more often when testing on my iPhone, but it happens in the simulator too. In particular, the assertion failure was:

Assertion failure: kind == GetGCThingTraceKind(*thingp), at /Users/rquesada/progs/Spidermonkey/js/src/gc/Marking.cpp:366

I'm not too familiar with embedding SpiderMonkey. Where should I look to start figuring out and fixing this bug? I only have one global object, one runtime, and one context in my app, and it's all running from the main thread.

Claudiu
  • 224,032
  • 165
  • 485
  • 680

1 Answers1

0

The reason was that I was passing a __block variable to JS_AddValueRoot. The JS_Add*Root functions operate on memory addresses, and the implementation is such that:

__block variables are initially allocated on the stack but if any block which references them is copied, they are moved onto the heap (malloced).

This led to the GCer thinking there was something where there wasn't which caused it to crash.

Claudiu
  • 224,032
  • 165
  • 485
  • 680