Bug 757375: concurrency changes, isolate state change assert fix (p=dtomack,r=jasowill)
authorDan Schaffer <Dan.Schaffer@adobe.com>
Fri, 17 Aug 2012 05:26:21 -0700
changeset 7525 c4affe1c9c2c15e0311623f80e77d0213e75d66f
parent 7524 7267380d93542a39fa6ef5daaea0a8c9a8997ec7
child 7526 5f318c60be19a67cc2b49b1eef99971208c6a4b0
push id4256
push userdschaffe@adobe.com
push dateMon, 20 Aug 2012 13:10:53 +0000
reviewersjasowill
bugs757375, 1098322, 1101422
Bug 757375: concurrency changes, isolate state change assert fix (p=dtomack,r=jasowill) integrate CL 1098322 CL@1101422
core/Isolate.cpp
test/acceptance/failconfig.txt
vmbase/Safepoint.cpp
vmbase/Safepoint.h
--- a/core/Isolate.cpp
+++ b/core/Isolate.cpp
@@ -85,16 +85,18 @@ namespace avmplus
         : m_primordialGiid(1) // eventually there will be many of those
         , m_activeIsolateCount(0)
         , m_inShutdown(false)
     {}
 
     Aggregate::~Aggregate()
     {
         m_threadCleanUps.deallocate();
+		if(MMgc::GCHeap::GetGCHeap()->GetStatus() == MMgc::kMemAbort)
+			vmbase::SafepointRecord::cleanupAfterOOM();
     }
 
     void Aggregate::destroy()
     {
         mmfx_delete(this);
     }
     
     Aggregate::Globals* Aggregate::m_globals  = NULL;
@@ -280,20 +282,23 @@ namespace avmplus
             } else if (to == Isolate::EXCEPTION) {
                 AvmAssert(from > Isolate::NEW);
 				isolate->m_interrupted = true;
                 isolate->stopRunLoop();
             } else if (to == Isolate::FAILED) {
                 AvmAssert(from == Isolate::NEW);
                 isolate->m_failed = true;
             } else if (to == Isolate::FINISHING) {
-                AvmAssert(from == Isolate::RUNNING || from == Isolate::STARTING);
+                AvmAssert(from == Isolate::RUNNING || from == Isolate::STARTING || from == Isolate::FINISHING);
                 AvmAssert(isolate->m_thread != NULL || m_primordialGiid == isolate->desc);
-                isolate->m_interrupted = true;
-                isolate->stopRunLoop();
+				if (from != Isolate::FINISHING)
+				{
+		            isolate->m_interrupted = true;
+					isolate->stopRunLoop();
+				}
             } else if (to == Isolate::TERMINATED) {
                 AvmAssert(from == Isolate::RUNNING || from == Isolate::STARTING || from == Isolate::FINISHING || from == Isolate::NEW);
 				isolate->m_interrupted = true;
 			}
 
         }
     }
 
@@ -982,18 +987,20 @@ namespace avmplus
             IsolateLister(Aggregate* aggregate, GCRef<ObjectVectorObject> workerVector, Toplevel* toplevel)
                 : m_aggregate(aggregate)
                 , m_workerVector(workerVector)
                 , m_toplevel(toplevel)
                 , m_index(0)
             {}
             virtual void each(int32_t, FixedHeapRef<Isolate> isolate) 
             {
-                //  Only list workers that are in the RUNNING state
-                if (isolate->m_aggregate->queryState(isolate) == Isolate::RUNNING)
+                // Only list workers that are in the RUNNING state
+                // fix for watson bug#3304797 intermittent hangs with avm2_mutex alchemy tests
+                // holding the global lock to query the isolate state is causing the issue see Aggregate::queryState()
+                if (isolate->m_state == Isolate::RUNNING)
                 {
                     GCRef<ScriptObject> interned = m_toplevel->getInternedObject(isolate);
                     if (interned == NULL) {
                         interned = isolate->workerObject(m_toplevel);
                     }
                     m_workerVector->setUintProperty(m_index++, interned->atom());
                 }
             }
--- a/test/acceptance/failconfig.txt
+++ b/test/acceptance/failconfig.txt
@@ -419,16 +419,15 @@ spidermonkey/js1_5/Regress/regress-36096
 spidermonkey/js1_5/Regress/regress-360969-04 , .*diff,, skip, Testcase outputs an execution time which is not part of the test and can cause a failure INVESTIGATE
 abcasm/bug_554915b, .* , , skip, testcase can cause a timeout INVESTIGATE
 
 regress/security/bug_689243b:Correct exception thrown , (x86|arm)-.*-Dinterp , , expectedfail, https://bugzilla.mozilla.org/show_bug.cgi?id=689243
 
 ####################
 # Workers
 ####################
-regress/.*243b,(x86-lnx-tvm-release-Dinterp|arm-android-tvm-release-Dinterp|arm-android-tvm-release-Dinterp|x86-win-tvm-release-Dinterp), , expectedfail, bug 
 regress/.*243a,.*,, skip, bug
 as3/ShellClasses/toplevel:exitcode, .*,, expectedfail, https://bugzilla.mozilla.org/show_bug.cgi?id=698855 System.exit(n) always exits 1
 as3/Workers/(ByteArrayWorkersLzma|WorkerDomain|Worker|WorkerErrors|regress/bug774294|regress/bug774302), (android|arm-) ,, skip, ARM platforms not supported https://bugzilla.mozilla.org/show_bug.cgi?id=755345
 as3/Workers/(ByteArrayWorkers|RemoteCall|WorkerCreateMax), .*, ,skip, https://bugzilla.mozilla.org/show_bug.cgi?id=774332
 as3/Workers/(Worker|WorkerDomain|WorkerCreateMax|WorkerErrors|regress/bug774294|regress/bug774302), -debug ,, skip, https://bugzilla.mozilla.org/show_bug.cgi?id=774294
 as3/Workers/ByteArrayWorkersLzma, -debug ,, skip, https://bugzilla.mozilla.org/show_bug.cgi?id=778727
 as3/Workers/ByteArrayWorkersLzma, x64-win-tvm ,, skip, https://bugzilla.mozilla.org/show_bug.cgi?id=780127
--- a/vmbase/Safepoint.cpp
+++ b/vmbase/Safepoint.cpp
@@ -70,17 +70,17 @@ namespace vmbase {
     {
         assert(SafepointRecord::hasCurrent());
         assert(SafepointRecord::current()->m_manager == this);
         assert(!inSafepointTask());
 
         // Serialize dispatch of safepoint tasks.
         SCOPE_LOCK_SP_NAMED(locker, m_requestMutex) {
             bool restart = false;
-            const volatile SafepointRecord* safepointRecord = m_records;
+            const volatile SafepointRecord* safepointRecord = NULL;
             do {
                 SafepointRecord::current()->m_status = SafepointRecord::SP_SAFE;
                 // Threads polling this SafepointManager will pass through a
                 // SafepointGate when they see m_requester as non-null.
                 
                 m_requester = VMPI_currentThread();
                 
                 safepointRecord = m_records;
--- a/vmbase/Safepoint.h
+++ b/vmbase/Safepoint.h
@@ -480,16 +480,23 @@ namespace vmbase {
         SafepointManager* manager() const;
 
 		/**
 		 * Sets the interruptLocation and isolateDesc for this record.
 		 */
 
 		void setLocationAndDesc (int32_t* location, int desc);
 
+    public:
+        /**
+         * Sets the calling thread's topmost
+         * SafepointRecord to NULL after OOM.
+         */
+		static void cleanupAfterOOM(){SafepointRecord::setCurrent(NULL);}
+
     private:
         /**
          * Sets the calling thread's topmost
          * SafepointRecord as the given record.
          */
         static void setCurrent(SafepointRecord* record);
 
     private: