From patchwork Sun Mar 13 20:08:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: itd X-Patchwork-Id: 37780 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id E965927BBEA; Sun, 13 Mar 2022 20:14:09 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 4E2AA27BBE9 for ; Sun, 13 Mar 2022 20:14:09 +0000 (GMT) Received: from localhost ([::1]:42886 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nTUbQ-0002Fb-F4 for patchwork@mira.cbaines.net; Sun, 13 Mar 2022 16:14:08 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50162) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nTUbK-0002FQ-3O for guix-patches@gnu.org; Sun, 13 Mar 2022 16:14:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:49442) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nTUbJ-0001VX-RA for guix-patches@gnu.org; Sun, 13 Mar 2022 16:14:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nTUbJ-0002yj-Mp for guix-patches@gnu.org; Sun, 13 Mar 2022 16:14:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#54376] [PATCH] gnu: python-mypy: Fix test errors on i686-linux. Resent-From: itd Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 13 Mar 2022 20:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 54376 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 54376@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.164720243411426 (code B ref -1); Sun, 13 Mar 2022 20:14:01 +0000 Received: (at submit) by debbugs.gnu.org; 13 Mar 2022 20:13:54 +0000 Received: from localhost ([127.0.0.1]:43339 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nTUbB-0002yD-Nd for submit@debbugs.gnu.org; Sun, 13 Mar 2022 16:13:54 -0400 Received: from lists.gnu.org ([209.51.188.17]:33352) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nTUbA-0002y6-Tz for submit@debbugs.gnu.org; Sun, 13 Mar 2022 16:13:53 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50130) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nTUbA-0002F9-QH for guix-patches@gnu.org; Sun, 13 Mar 2022 16:13:52 -0400 Received: from mailout3.rbg.tum.de ([131.159.0.8]:41915) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nTUb7-0001UP-6y for guix-patches@gnu.org; Sun, 13 Mar 2022 16:13:52 -0400 Received: from mailrelay1.rbg.tum.de (mailrelay1.in.tum.de [131.159.254.14]) by mailout3.rbg.tum.de (Postfix) with ESMTPS id 9F7F81017C8 for ; Sun, 13 Mar 2022 21:08:04 +0100 (CET) Received: by mailrelay1.rbg.tum.de (Postfix, from userid 112) id 9BD6F77; Sun, 13 Mar 2022 21:08:04 +0100 (CET) Received: from mailrelay1.rbg.tum.de (localhost [127.0.0.1]) by mailrelay1.rbg.tum.de (Postfix) with ESMTP id 25B3C76 for ; Sun, 13 Mar 2022 21:08:04 +0100 (CET) Received: from mail.net.in.tum.de (mail.net.in.tum.de [IPv6:2001:4ca0:2001:14:216:3eff:fe52:ed14]) by mailrelay1.rbg.tum.de (Postfix) with ESMTP id 2418875 for ; Sun, 13 Mar 2022 21:08:04 +0100 (CET) Received: from amnesix.net.in.tum.de (amnesix.net.in.tum.de [IPv6:2001:4ca0:2001:11:e2d5:5eff:fea9:55ca]) by mail.net.in.tum.de (Postfix) with ESMTP id 02714282104F; Sun, 13 Mar 2022 21:08:03 +0100 (CET) From: itd Date: Sun, 13 Mar 2022 21:08:03 +0100 Message-ID: <87r1757h0c.fsf@localhost> MIME-Version: 1.0 Received-SPF: pass client-ip=131.159.0.8; envelope-from=itd@net.in.tum.de; helo=mailout3.rbg.tum.de X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches From a8de61a3f6ca50bf4a68222532029e8e9e84c510 Mon Sep 17 00:00:00 2001 * gnu/packages/patches/python-mypy-12332.patch: New patch. * gnu/local.mk (dist_patch_DATA): Add it. * gnu/packages/python-check.scm (python-mypy)[source]: Use patch "python-mypy-12332.patch" to avoid overflow issues resulting in test failures. --- Hi, currently, python-mypy on i686-linux does not build [0] due to test errors [1]. To my knowledge, the merged fix [2] is not part of a release yet. But, it [2] fixes the python-mypy build for me. Please consider applying it. Thanks! [0]: https://ci.guix.gnu.org/build/484670/details [1]: https://github.com/python/mypy/issues/11148 [2]: https://github.com/python/mypy/pull/12332 Regards itd gnu/local.mk | 1 + gnu/packages/patches/python-mypy-12332.patch | 68 ++++++++++++++++++++ gnu/packages/python-check.scm | 4 +- 3 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 gnu/packages/patches/python-mypy-12332.patch diff --git a/gnu/local.mk b/gnu/local.mk index 484757b207..05d01c858f 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1716,6 +1716,7 @@ dist_patch_DATA = \ %D%/packages/patches/python-versioneer-guix-support.patch \ %D%/packages/patches/python-waitress-fix-tests.patch \ %D%/packages/patches/python-werkzeug-tests.patch \ + %D%/packages/patches/python-mypy-12332.patch \ %D%/packages/patches/qemu-build-info-manual.patch \ %D%/packages/patches/qemu-glibc-2.27.patch \ %D%/packages/patches/qemu-glibc-2.30.patch \ diff --git a/gnu/packages/patches/python-mypy-12332.patch b/gnu/packages/patches/python-mypy-12332.patch new file mode 100644 index 0000000000..d43cf42ed1 --- /dev/null +++ b/gnu/packages/patches/python-mypy-12332.patch @@ -0,0 +1,68 @@ +From 518c864805dd93e62d59439e665a0ce9d6778419 Mon Sep 17 00:00:00 2001 +From: Ekin Dursun +Date: Thu, 10 Mar 2022 22:06:48 +0300 +Subject: [PATCH] mypyc: Fix overflow in id function (CPyTagged_Id) + +In CPython, the id of an object is its address. It's computed by +converting the pointer to an unsigned integer (PyLong_FromVoidPtr). A +similar logic is present here, pointer is converted to a Py_ssize_t and +CPyTagged_FromSsize_t is called with that integer. + +There is a problem with that approach: Py_ssize_t cannot hold every +pointer value. Sometimes overflow happens and CPyTagged_FromSsize_t is +called with a negative integer. + +With the new approach, the number is checked: If it fits in a +Py_ssize_t, CPyTagged_FromSsize_t is called. If not, it is directly +converted to a PyObject using PyLong_FromVoidPtr. +--- + mypyc/lib-rt/CPy.h | 1 + + mypyc/lib-rt/int_ops.c | 9 +++++++++ + mypyc/lib-rt/misc_ops.c | 2 +- + 3 files changed, 11 insertions(+), 1 deletion(-) + +diff --git a/mypyc/lib-rt/CPy.h b/mypyc/lib-rt/CPy.h +index 987819154ab..9f5ae52d4e4 100644 +--- a/mypyc/lib-rt/CPy.h ++++ b/mypyc/lib-rt/CPy.h +@@ -121,6 +121,7 @@ static inline size_t CPy_FindAttrOffset(PyTypeObject *trait, CPyVTableItem *vtab + + + CPyTagged CPyTagged_FromSsize_t(Py_ssize_t value); ++CPyTagged CPyTagged_FromVoidPtr(void *ptr); + CPyTagged CPyTagged_FromObject(PyObject *object); + CPyTagged CPyTagged_StealFromObject(PyObject *object); + CPyTagged CPyTagged_BorrowFromObject(PyObject *object); +diff --git a/mypyc/lib-rt/int_ops.c b/mypyc/lib-rt/int_ops.c +index 1275f2c1057..edf06314161 100644 +--- a/mypyc/lib-rt/int_ops.c ++++ b/mypyc/lib-rt/int_ops.c +@@ -26,6 +26,15 @@ CPyTagged CPyTagged_FromSsize_t(Py_ssize_t value) { + } + } + ++CPyTagged CPyTagged_FromVoidPtr(void *ptr) { ++ if ((uintptr_t)ptr > PY_SSIZE_T_MAX) { ++ PyObject *object = PyLong_FromVoidPtr(ptr); ++ return ((CPyTagged)object) | CPY_INT_TAG; ++ } else { ++ return CPyTagged_FromSsize_t((Py_ssize_t)ptr); ++ } ++} ++ + CPyTagged CPyTagged_FromObject(PyObject *object) { + int overflow; + // The overflow check knows about CPyTagged's width +diff --git a/mypyc/lib-rt/misc_ops.c b/mypyc/lib-rt/misc_ops.c +index cebd1cf997f..dcce89d9072 100644 +--- a/mypyc/lib-rt/misc_ops.c ++++ b/mypyc/lib-rt/misc_ops.c +@@ -437,7 +437,7 @@ CPyPickle_GetState(PyObject *obj) + } + + CPyTagged CPyTagged_Id(PyObject *o) { +- return CPyTagged_FromSsize_t((Py_ssize_t)o); ++ return CPyTagged_FromVoidPtr(o); + } + + #define MAX_INT_CHARS 22 diff --git a/gnu/packages/python-check.scm b/gnu/packages/python-check.scm index 05a378601f..5bbe544113 100644 --- a/gnu/packages/python-check.scm +++ b/gnu/packages/python-check.scm @@ -1658,7 +1658,9 @@ supported by the MyPy typechecker.") (file-name (git-file-name name version)) (sha256 (base32 - "1v83flrdxh8grcp40qw04q4hzjflih9xwib64078vsxv2w36f817")))) + "1v83flrdxh8grcp40qw04q4hzjflih9xwib64078vsxv2w36f817")) + (patches + (search-patches "python-mypy-12332.patch")))) (build-system python-build-system) (arguments `(#:phases