From bd1e47165c3f2427cd28c4af8bc2479ea6b113e0 Mon Sep 17 00:00:00 2001 From: Bill McCloskey Date: Wed, 12 Dec 2012 13:17:45 -0800 Subject: [PATCH] Bug 819443 - Make sure we don't finalize on background thread (r=luke) --- js/src/jscntxt.h | 4 ++++ js/src/jsobjinlines.h | 3 +++ 2 files changed, 7 insertions(+) diff --git a/js/src/jscntxt.h b/js/src/jscntxt.h index a5b378f1561..742b0ccf97e 100644 --- a/js/src/jscntxt.h +++ b/js/src/jscntxt.h @@ -482,7 +482,11 @@ struct JSRuntime : js::RuntimeFriendFields void clearOwnerThread(); void setOwnerThread(); JS_FRIEND_API(void) abortIfWrongThread() const; +#ifdef DEBUG JS_FRIEND_API(void) assertValidThread() const; +#else + void assertValidThread() const {} +#endif private: void *ownerThread_; public: diff --git a/js/src/jsobjinlines.h b/js/src/jsobjinlines.h index b8896033a48..347de61f8a5 100644 --- a/js/src/jsobjinlines.h +++ b/js/src/jsobjinlines.h @@ -225,6 +225,9 @@ JSObject::finalize(js::FreeOp *fop) js::Probes::finalizeObject(this); if (!IsBackgroundFinalized(getAllocKind())) { + /* Assert we're on the main thread. */ + fop->runtime()->assertValidThread(); + /* * Finalize obj first, in case it needs map and slots. Objects with * finalize hooks are not finalized in the background, as the class is