Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r2718:50807f7805db
Date: 2016-06-09 08:37 +0200
http://bitbucket.org/cffi/cffi/changeset/50807f7805db/

Log:    Issue #266: I think it would show up here, so better change the
        assert() into a real test that runs also on non-debugging
        compilation.

diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -5258,7 +5258,20 @@
                         "libffi failed to build this callback");
         goto error;
     }
-    assert(closure->user_data == infotuple);
+    if (closure->user_data != infotuple) {
+        /* Issue #266.  Should not occur, but could, if we are using
+           at runtime a version of libffi compiled with a different
+           'ffi_closure' structure than the one we expect from ffi.h
+           (e.g. difference in details of the platform): a difference
+           in FFI_TRAMPOLINE_SIZE means that the 'user_data' field
+           ends up somewhere else, and so the test above fails.
+        */
+        PyErr_SetString(PyExc_SystemError,
+            "ffi_prep_closure(): bad user_data (it seems that the "
+            "version of the libffi library seen at runtime is "
+            "different from the 'ffi.h' file seen at compile-time)");
+        goto error;
+    }
     return (PyObject *)cd;
 
  error:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to