Bug 816046 - Intermittent "Assertion failure: key.kind != CrossCompartmentKey::StringWrapper r=billm

--HG--
extra : rebase_source : e57dc40bbd5648cabcaf2805b984e921577989f5
This commit is contained in:
Jon Coppeard 2012-11-28 17:39:12 +00:00
parent f934392869
commit e0b573304b

View File

@ -337,7 +337,22 @@ JSCompartment::wrap(JSContext *cx, Value *vp, JSObject *existing)
if (!wrapped)
return false;
vp->setString(wrapped);
return crossCompartmentWrappers.put(orig, *vp);
if (!crossCompartmentWrappers.put(orig, *vp))
return false;
if (str->compartment()->isGCMarking()) {
/*
* All string wrappers are dropped when collection starts, but we
* just created a new one. Mark the wrapped string to stop it being
* finalized, because if it was then the pointer in this
* compartment's wrapper map would be left dangling.
*/
JSString *tmp = str;
MarkStringUnbarriered(&rt->gcMarker, &tmp, "wrapped string");
JS_ASSERT(tmp == str);
}
return true;
}
RootedObject obj(cx, &vp->toObject());