[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-1+backports' - external/python3

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 1 09:17:37 UTC 2021


 external/python3/0001-remove-long-double-from-ctypes-value-union.patch.1 |   34 ++++++++++
 external/python3/UnpackedTarball_python3.mk                              |    1 
 2 files changed, 35 insertions(+)

New commits:
commit 178542f70af6fa86b391b6f4534ff545c10e7223
Author:     Michael Stahl <michael.stahl at allotropia.de>
AuthorDate: Fri May 14 20:37:23 2021 +0200
Commit:     Michael Stahl <michael.stahl at allotropia.de>
CommitDate: Tue Jun 1 11:17:01 2021 +0200

    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
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115980
    Tested-by: Michael Stahl <michael.stahl at allotropia.de>
    Reviewed-by: Michael Stahl <michael.stahl at allotropia.de>

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 at 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 81a392f76f48..5e29cf21b238 100644
--- a/external/python3/UnpackedTarball_python3.mk
+++ b/external/python3/UnpackedTarball_python3.mk
@@ -27,6 +27,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,python3,\
 	external/python3/python-3.5.tweak.strip.soabi.patch \
 	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)),)


More information about the Libreoffice-commits mailing list