diff --git a/js/src/gc/Marking.cpp b/js/src/gc/Marking.cpp index 4487594f97a8..4a0c68f4fd91 100644 --- a/js/src/gc/Marking.cpp +++ b/js/src/gc/Marking.cpp @@ -1662,6 +1662,18 @@ ObjectDenseElementsMayBeMarkable(NativeObject* nobj) return mayBeMarkable; } +static inline void +CheckForCompartmentMismatch(JSObject* obj, JSObject* obj2) +{ +#ifdef DEBUG + if (MOZ_UNLIKELY(obj->compartment() != obj2->compartment())) { + fprintf(stderr, "Compartment mismatch in pointer from %s object slot to %s object\n", + obj->getClass()->name, obj2->getClass()->name); + MOZ_CRASH("Compartment mismatch"); + } +#endif +} + inline void GCMarker::processMarkStackTop(SliceBudget& budget) { @@ -1732,7 +1744,7 @@ GCMarker::processMarkStackTop(SliceBudget& budget) traverseEdge(obj, v.toString()); } else if (v.isObject()) { JSObject* obj2 = &v.toObject(); - MOZ_ASSERT(obj->compartment() == obj2->compartment()); + CheckForCompartmentMismatch(obj, obj2); if (mark(obj2)) { // Save the rest of this value array for later and start scanning obj2's children. pushValueArray(obj, vp, end);