[pypy-commit] pypy default: We must setup the GIL here, in case the callback is invoked in some

arigo noreply at buildbot.pypy.org
Thu Sep 5 10:29:08 CEST 2013


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r66785:0e638a269c11
Date: 2013-09-03 16:47 +0200
http://bitbucket.org/pypy/pypy/changeset/0e638a269c11/

Log:	We must setup the GIL here, in case the callback is invoked in some
	other non-Pythonic thread. This is the same as cffi on CPython.
	This should fix the shadowstack failure of test_callback_in_thread.

diff --git a/pypy/module/_cffi_backend/ccallback.py b/pypy/module/_cffi_backend/ccallback.py
--- a/pypy/module/_cffi_backend/ccallback.py
+++ b/pypy/module/_cffi_backend/ccallback.py
@@ -54,6 +54,13 @@
         if rffi.cast(lltype.Signed, res) != clibffi.FFI_OK:
             raise OperationError(space.w_SystemError,
                 space.wrap("libffi failed to build this callback"))
+        #
+        # We must setup the GIL here, in case the callback is invoked in
+        # some other non-Pythonic thread.  This is the same as cffi on
+        # CPython.
+        if space.config.translation.thread:
+            from pypy.module.thread.os_thread import setup_threads
+            setup_threads(space)
 
     def get_closure(self):
         return rffi.cast(clibffi.FFI_CLOSUREP, self._cdata)


More information about the pypy-commit mailing list