mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 549743: Abort if cycle collected object is refcounted from threads other than the main thread. Such refcounting will randomly cause leaks and crashes anyway, so better crash up front to make sure developers notice. r=dbaron
This commit is contained in:
parent
ca0c6a507d
commit
8e86b28780
@ -1189,13 +1189,13 @@ Fault(const char *msg, PtrInfo *pi)
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline bool
|
||||
CheckMainThreadIfFast()
|
||||
static inline void
|
||||
AbortIfOffMainThreadIfCheckFast()
|
||||
{
|
||||
#if defined(XP_WIN) || defined(NS_TLS)
|
||||
return NS_IsMainThread();
|
||||
#else
|
||||
return true;
|
||||
if (!NS_IsMainThread()) {
|
||||
NS_RUNTIMEABORT("Main-thread-only object used off the main thread");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -2309,8 +2309,7 @@ nsCycleCollector_isScanSafe(nsISupports *s)
|
||||
PRBool
|
||||
nsCycleCollector::Suspect(nsISupports *n)
|
||||
{
|
||||
if (!CheckMainThreadIfFast())
|
||||
return PR_FALSE;
|
||||
AbortIfOffMainThreadIfCheckFast();
|
||||
|
||||
// Re-entering ::Suspect during collection used to be a fault, but
|
||||
// we are canonicalizing nsISupports pointers using QI, so we will
|
||||
@ -2350,12 +2349,7 @@ nsCycleCollector::Suspect(nsISupports *n)
|
||||
PRBool
|
||||
nsCycleCollector::Forget(nsISupports *n)
|
||||
{
|
||||
if (!CheckMainThreadIfFast()) {
|
||||
if (!mParams.mDoNothing) {
|
||||
Fault("Forget called off main thread");
|
||||
}
|
||||
return PR_TRUE; // it's as good as forgotten
|
||||
}
|
||||
AbortIfOffMainThreadIfCheckFast();
|
||||
|
||||
// Re-entering ::Forget during collection used to be a fault, but
|
||||
// we are canonicalizing nsISupports pointers using QI, so we will
|
||||
@ -2389,8 +2383,7 @@ nsCycleCollector::Forget(nsISupports *n)
|
||||
nsPurpleBufferEntry*
|
||||
nsCycleCollector::Suspect2(nsISupports *n)
|
||||
{
|
||||
if (!CheckMainThreadIfFast())
|
||||
return nsnull;
|
||||
AbortIfOffMainThreadIfCheckFast();
|
||||
|
||||
// Re-entering ::Suspect during collection used to be a fault, but
|
||||
// we are canonicalizing nsISupports pointers using QI, so we will
|
||||
@ -2431,8 +2424,7 @@ nsCycleCollector::Suspect2(nsISupports *n)
|
||||
PRBool
|
||||
nsCycleCollector::Forget2(nsPurpleBufferEntry *e)
|
||||
{
|
||||
if (!CheckMainThreadIfFast())
|
||||
return PR_FALSE;
|
||||
AbortIfOffMainThreadIfCheckFast();
|
||||
|
||||
// Re-entering ::Forget during collection used to be a fault, but
|
||||
// we are canonicalizing nsISupports pointers using QI, so we will
|
||||
|
Loading…
Reference in New Issue
Block a user