diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2021-05-14 20:37:23 +0200 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2021-05-17 10:18:13 +0200 |
commit | 6ccb5f0cd44293730c6604184683ac6165f8b055 (patch) | |
tree | 58c7c08399d5aa16417f8d2b64ab53b45ec6bbd3 | |
parent | Missing include (for std::min) (diff) | |
download | core-6ccb5f0cd44293730c6604184683ac6165f8b055.tar.gz core-6ccb5f0cd44293730c6604184683ac6165f8b055.zip |
python3: fix segfault importing ctypes
on this line: CFUNCTYPE(c_int)(lambda:None)
python segfaults when compiled with GCC 11.
│ 0x7f7e53a5d64c <PyCFuncPtr_new+220> call 0x7f7e53a5c3d0 <GenericPyCData_new> │
│ 0x7f7e53a5d651 <PyCFuncPtr_new+225> mov %rax,%r13 │
│ 0x7f7e53a5d654 <PyCFuncPtr_new+228> test %rax,%rax │
│ 0x7f7e53a5d657 <PyCFuncPtr_new+231> je 0x7f7e53a5d990 <PyCFuncPtr_new+1056> │
│ 0x7f7e53a5d65d <PyCFuncPtr_new+237> mov 0x88(%rsp),%rax │
│ 0x7f7e53a5d665 <PyCFuncPtr_new+245> movq %r15,%xmm0 │
│ 0x7f7e53a5d66a <PyCFuncPtr_new+250> movq %rax,%xmm1 │
│ 0x7f7e53a5d66f <PyCFuncPtr_new+255> addq $0x1,(%rax) │
│ 0x7f7e53a5d673 <PyCFuncPtr_new+259> mov 0x10(%r13),%rax │
│ 0x7f7e53a5d677 <PyCFuncPtr_new+263> punpcklqdq %xmm1,%xmm0 │
│ >0x7f7e53a5d67b <PyCFuncPtr_new+267> movaps %xmm0,0x60(%r13)
(rr) p/x ($r13 + 0x60) % 16
$10 = 0x8
(rr) p &self->b_value
$11 = (union value *) 0x7f7e53c0fea8
b_value contains "long double" which requires 16 byte alignment so the
subsequent 2 pointers have to be 16 byte aligned, so gcc generates "movaps"
instruction which requires 16 byte alignment, but they're 8 byte aligned.
Change-Id: I8d57311c5dc0d33ab0f7beeb6fee91299bd3de67
(cherry picked from commit 6a38eafc17c7b1b8972e648db19dc841c3f9902e)
-rw-r--r-- | external/python3/0001-remove-long-double-from-ctypes-value-union.patch.1 | 34 | ||||
-rw-r--r-- | external/python3/UnpackedTarball_python3.mk | 1 |
2 files changed, 35 insertions, 0 deletions
diff --git a/external/python3/0001-remove-long-double-from-ctypes-value-union.patch.1 b/external/python3/0001-remove-long-double-from-ctypes-value-union.patch.1 new file mode 100644 index 000000000000..8cdaf84de37c --- /dev/null +++ b/external/python3/0001-remove-long-double-from-ctypes-value-union.patch.1 @@ -0,0 +1,34 @@ +From 6d999803a07ef5e01f0048d4f276e9cf4401a23d Mon Sep 17 00:00:00 2001 +From: Benjamin Peterson <benjamin@python.org> +Date: Mon, 5 Sep 2016 16:24:52 -0700 +Subject: [PATCH] remove long double from ctypes value union + +It is unused. It also forces a 16-byte alignment, which creates problems because +Python's allocator only uses 8-byte alignment. +--- + Modules/_ctypes/ctypes.h | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/Modules/_ctypes/ctypes.h b/Modules/_ctypes/ctypes.h +index 0d3f7241ca..d80ea82cee 100644 +--- a/Modules/_ctypes/ctypes.h ++++ b/Modules/_ctypes/ctypes.h +@@ -34,7 +34,6 @@ union value { + #ifdef HAVE_LONG_LONG + PY_LONG_LONG ll; + #endif +- long double D; + }; + + /* +@@ -306,7 +305,6 @@ struct tagPyCArgObject { + #ifdef HAVE_LONG_LONG + PY_LONG_LONG q; + #endif +- long double D; + double d; + float f; + void *p; +-- +2.31.1 + diff --git a/external/python3/UnpackedTarball_python3.mk b/external/python3/UnpackedTarball_python3.mk index f231b5970eaf..41d9e4d78ff5 100644 --- a/external/python3/UnpackedTarball_python3.mk +++ b/external/python3/UnpackedTarball_python3.mk @@ -28,6 +28,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,python3,\ external/python3/darwin.patch.0 \ external/python3/0001-3.6-bpo-17239-Disable-external-entities-in-SAX-parse.patch.1 \ external/python3/0001-3.6-closes-bpo-42938-Replace-snprintf-with-Python-un.patch.1 \ + external/python3/0001-remove-long-double-from-ctypes-value-union.patch.1 \ )) ifneq ($(filter DRAGONFLY FREEBSD LINUX NETBSD OPENBSD SOLARIS,$(OS)),) |