2011-01-18 Dirk Pranke <dpranke@chromium.org>
authordpranke@chromium.org <dpranke@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Jan 2011 23:21:03 +0000 (23:21 +0000)
committerdpranke@chromium.org <dpranke@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Jan 2011 23:21:03 +0000 (23:21 +0000)
        Reviewed by Mihai Parparita.

        Fix a small race condition that could cause the unit tests for
        new-run-webkit-tests to fail in a multithreaded environment.
        There was a small window in the code where one thread would
        check to see if a thread had raised an exception, do something,
        and then check to see if the thread was alive. If the other
        thread raised an exception and exited in between these two
        steps, the exception would be lost. Flipping the order of the
        two checks fixes the race, since we will now always check for an
        exception on the thread before exiting.

        https://bugs.webkit.org/show_bug.cgi?id=51579

        * Scripts/webkitpy/layout_tests/layout_package/message_broker.py:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76073 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/webkitpy/layout_tests/layout_package/message_broker.py

index bcdcb33e24a2256907ac0aea935548370cf7fd77..3601d3df5031bfdbd90eecfb664f9815f3cf4925 100644 (file)
@@ -1,3 +1,21 @@
+2011-01-18  Dirk Pranke  <dpranke@chromium.org>
+
+        Reviewed by Mihai Parparita.
+
+        Fix a small race condition that could cause the unit tests for
+        new-run-webkit-tests to fail in a multithreaded environment.
+        There was a small window in the code where one thread would
+        check to see if a thread had raised an exception, do something,
+        and then check to see if the thread was alive. If the other
+        thread raised an exception and exited in between these two
+        steps, the exception would be lost. Flipping the order of the
+        two checks fixes the race, since we will now always check for an
+        exception on the thread before exiting.
+
+        https://bugs.webkit.org/show_bug.cgi?id=51579
+
+        * Scripts/webkitpy/layout_tests/layout_package/message_broker.py:
+
 2011-01-18  Eric Seidel  <eric@webkit.org>
 
         Reviewed by Adam Barth.
index e0ca8db1d8aa5504a06e18465e4572bf62fee1d5..481c6170494856add5556eab5572b1e712b500bc 100644 (file)
@@ -144,6 +144,13 @@ class MultiThreadedBroker(WorkerMessageBroker):
             some_thread_is_alive = False
             t = time.time()
             for thread in threads:
+                if thread.isAlive():
+                    some_thread_is_alive = True
+                    next_timeout = thread.next_timeout()
+                    if next_timeout and t > next_timeout:
+                        log_wedged_worker(thread.getName(), thread.id())
+                        thread.clear_next_timeout()
+
                 exception_info = thread.exception_info()
                 if exception_info is not None:
                     # Re-raise the thread's exception here to make it
@@ -152,13 +159,6 @@ class MultiThreadedBroker(WorkerMessageBroker):
                     # to have passed.
                     raise exception_info[0], exception_info[1], exception_info[2]
 
-                if thread.isAlive():
-                    some_thread_is_alive = True
-                    next_timeout = thread.next_timeout()
-                    if next_timeout and t > next_timeout:
-                        log_wedged_worker(thread.getName(), thread.id())
-                        thread.clear_next_timeout()
-
             self._test_runner.update()
 
             if some_thread_is_alive: