Update libffi commit (#2350)

All libffi tests pass now. The only failing ctypes test is test_callback_too_many_args which doesn't segfault anymore, it only soft fails. Planning to submit a PR to cpython that fixes test_callback_too_many_args.
See also:
bugs.python.org/issue47208
https://github.com/emscripten-core/emscripten/pull/16658
This commit is contained in:
Hood Chatham 2022-04-04 21:18:20 -07:00 committed by GitHub
parent 8ffd03f48e
commit eb8afb00c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 69 additions and 19 deletions

View File

@ -387,7 +387,8 @@ class NodeWrapper(SeleniumWrapper):
def init_node(self):
os.chdir("build")
self.p = pexpect.spawn(
f"node --expose-gc ../tools/node_test_driver.js {self.base_url}", timeout=60
f"node --expose-gc --experimental-wasm-bigint ../tools/node_test_driver.js {self.base_url}",
timeout=60,
)
self.p.setecho(False)
self.p.delaybeforesend = None

View File

@ -27,7 +27,7 @@ BZIP2URL=https://sourceware.org/pub/bzip2/bzip2-1.0.2.tar.gz
FFIBUILD=$(ROOT)/build/libffi
LIBFFIREPO=https://github.com/hoodmane/libffi-emscripten
LIBFFI_COMMIT=d6666df2a2820e0548a66166021ddae04a11a2db
LIBFFI_COMMIT=008d7aafde297703eb2f259c969aebf301b01a6d
all: $(INSTALL)/lib/$(LIB) $(INSTALL)/lib/libffi.a

View File

@ -1,7 +1,7 @@
From d94b4b85f87cb2c0c83f605028acbe2de4ab028a Mon Sep 17 00:00:00 2001
From 5269845b6390efedb10dbdaec4d5b4b73ca76445 Mon Sep 17 00:00:00 2001
From: Hood <hood@mit.edu>
Date: Fri, 3 Sep 2021 18:08:26 -0700
Subject: [PATCH 07/10] Patch in keyboard interrupt handling
Subject: [PATCH 06/10] Patch in keyboard interrupt handling
This patch adds a callback called pyodide_callback with signature
`int callback(void)` to the main loop in `ceval.c`. This function gets called once

View File

@ -1,7 +1,7 @@
From c1072b871866ac92abf18f159420dbf424902702 Mon Sep 17 00:00:00 2001
From e053e51c4e4c84423c4389463b12defb5bca7b4d Mon Sep 17 00:00:00 2001
From: Hood <hood@mit.edu>
Date: Tue, 22 Jun 2021 20:12:45 -0700
Subject: [PATCH 08/10] Remove duplicate symbols from cfield.c
Subject: [PATCH 07/10] Remove duplicate symbols from cfield.c
These symbols are already defined by libffi.
---

View File

@ -1,7 +1,7 @@
From 16abd462459b36c73db23b776f1eb5ab2c0c7813 Mon Sep 17 00:00:00 2001
From fcd212640bb74988c31d3ba434bcac83cbcb087c Mon Sep 17 00:00:00 2001
From: Hood <hood@mit.edu>
Date: Thu, 24 Jun 2021 14:55:10 -0700
Subject: [PATCH 09/10] xfail core ctypes tests that don't work
Subject: [PATCH 08/10] xfail core ctypes tests that don't work
PyCode_SetExtra doesn't work and ctypes doesn't seem to work with variadic functions including PyUnicode_FromFormat/
---

View File

@ -1,7 +1,7 @@
From 1775d9b346016fec4eb22f7b46d6aa8ece8aa761 Mon Sep 17 00:00:00 2001
From 9a3c6ecd36a405e3d67059436cc54055cdcd465a Mon Sep 17 00:00:00 2001
From: Hood Chatham <roberthoodchatham@gmail.com>
Date: Tue, 1 Mar 2022 17:06:53 -0800
Subject: [PATCH 10/10] Fix _PyImport_LoadDynamicModuleWithSpec fpcast
Subject: [PATCH 09/10] Fix _PyImport_LoadDynamicModuleWithSpec fpcast
---
Python/importdl.c | 11 ++++++++++-

View File

@ -0,0 +1,52 @@
From 7b550d8ce20d48ebb1a4f240d6cd5e8a72a430b5 Mon Sep 17 00:00:00 2001
From: Hood Chatham <roberthoodchatham@gmail.com>
Date: Fri, 1 Apr 2022 18:55:11 -0700
Subject: [PATCH 10/10] bpo-47197: Fix void return type handling in ctypes
_ctypes_get_ffi_type never returns ffi_type_void. If the
return type is specified as None, we need set the libffi
return type to void, but just taking the output from
_ctypes_get_ffi_type will make the return type be sint.
This fixes two spots where ctypes accidentally converts
None return type to sint rather than void, causing crashes
on Emscripten targets.
---
Modules/_ctypes/callbacks.c | 2 +-
Modules/_ctypes/callproc.c | 7 ++++++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c
index 5a4d1c543f..ef28b93551 100644
--- a/Modules/_ctypes/callbacks.c
+++ b/Modules/_ctypes/callbacks.c
@@ -403,7 +403,7 @@ CThunkObject *_ctypes_alloc_callback(PyObject *callable,
#endif
result = ffi_prep_cif(&p->cif, cc,
Py_SAFE_DOWNCAST(nArgs, Py_ssize_t, int),
- _ctypes_get_ffi_type(restype),
+ p->ffi_restype,
&p->atypes[0]);
if (result != FFI_OK) {
PyErr_Format(PyExc_RuntimeError,
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c
index ddf289e3e8..d6513c0e1f 100644
--- a/Modules/_ctypes/callproc.c
+++ b/Modules/_ctypes/callproc.c
@@ -1219,7 +1219,12 @@ PyObject *_ctypes_callproc(PPROC pProc,
}
}
- rtype = _ctypes_get_ffi_type(restype);
+ if (restype == Py_None) {
+ rtype = &ffi_type_void;
+ } else {
+ rtype = _ctypes_get_ffi_type(restype);
+ }
+
resbuf = alloca(max(rtype->size, sizeof(ffi_arg)));
#ifdef _Py_MEMORY_SANITIZER
--
2.25.1

View File

@ -120,6 +120,11 @@ substitutions:
possible to use an async Python function as a Javascript event handler.
{pr}`2319`
- {{ Enhancement }} `libffi-emscripten` now passes all libffi tests. All
`ctypes` tests pass now except for `test_callback_too_many_args` (and we have
a plan to fix `test_callback_too_many_args` upstream).
{pr}`2350`
- {{ Enhancement }} Support ANSI escape codes in the Pyodide console.
{pr}`2345`

View File

@ -190,16 +190,8 @@
- test_csv
- test_ctypes:
skip:
# See https://bugs.python.org/issue47208
- test_callback_too_many_args
- test_callback_large_struct
- CFunctions
- test_struct_return_2H
- FunctionTestCase
skip-node:
- test_longlong_callbacks
- test_longdouble
- test_longlong
- test_ulonglong
- test_curses
- test_dataclasses
- test_datetime: