Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r87392:c540b2c9656a
Date: 2016-09-26 10:53 +0100
http://bitbucket.org/pypy/pypy/changeset/c540b2c9656a/

Log:    Aaargh again. Borked the locking here. Shows up as a rare crash in
        test_lib_pypy/cffi_tests/embedding/test_thread.

diff --git a/rpython/translator/c/src/threadlocal.c 
b/rpython/translator/c/src/threadlocal.c
--- a/rpython/translator/c/src/threadlocal.c
+++ b/rpython/translator/c/src/threadlocal.c
@@ -15,9 +15,10 @@
 static int check_valid(void);
 
 void _RPython_ThreadLocals_Acquire(void) {
-    while (!pypy_lock_test_and_set(&pypy_threadlocal_lock, 1)) {
-        /* busy loop */
-    }
+    long old_value;
+    do {
+        old_value = pypy_lock_test_and_set(&pypy_threadlocal_lock, 1);
+    } while (old_value != 0);   /* busy loop */
     assert(check_valid());
 }
 void _RPython_ThreadLocals_Release(void) {
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to