From f475509677dc297072cd70c90839ca922b23d017 Mon Sep 17 00:00:00 2001 From: Felipe Rodrigues Date: Sat, 31 Jul 2021 10:06:36 -0300 Subject: [PATCH 1/8] fix outdated reference to Py_USING_MEMORY_DEBUGGER --- Misc/README.valgrind | 2 -- 1 file changed, 2 deletions(-) diff --git a/Misc/README.valgrind b/Misc/README.valgrind index b483b2ea60a4d2..63ac48d2af86b9 100644 --- a/Misc/README.valgrind +++ b/Misc/README.valgrind @@ -14,8 +14,6 @@ are still two things you must do to suppress the warnings. First, you must use a suppressions file. One is supplied in Misc/valgrind-python.supp. Second, you must do one of the following: - * Uncomment Py_USING_MEMORY_DEBUGGER in Objects/obmalloc.c, - then rebuild Python * Uncomment the lines in Misc/valgrind-python.supp that suppress the warnings for PyObject_Free and PyObject_Realloc From 685e1eea4b5b9cf3c35c8456031b4330efa47175 Mon Sep 17 00:00:00 2001 From: Felipe Bidu Rodrigues Date: Mon, 13 Sep 2021 10:02:33 -0300 Subject: [PATCH 2/8] Remove Py_USING_MEMORY_DEBUGGER from docs and dtoa --- Misc/valgrind-python.supp | 4 +- Python/dtoa.c | 96 --------------------------------------- 2 files changed, 2 insertions(+), 98 deletions(-) diff --git a/Misc/valgrind-python.supp b/Misc/valgrind-python.supp index c9c45ba7ed6de4..295ae382ee7a9f 100644 --- a/Misc/valgrind-python.supp +++ b/Misc/valgrind-python.supp @@ -7,8 +7,8 @@ # valgrind --tool=memcheck --suppressions=Misc/valgrind-python.supp \ # ./python -E ./Lib/test/regrtest.py -u gui,network # -# You must edit Objects/obmalloc.c and uncomment Py_USING_MEMORY_DEBUGGER -# to use the preferred suppressions with address_in_range. +# You must edit Objects/obmalloc.c to use the preferred +# suppressions with address_in_range. # # If you do not want to recompile Python, you can uncomment # suppressions for _PyObject_Free and _PyObject_Realloc. diff --git a/Python/dtoa.c b/Python/dtoa.c index e629b296426f31..05410e6ab9fdbc 100644 --- a/Python/dtoa.c +++ b/Python/dtoa.c @@ -330,7 +330,6 @@ Bigint { typedef struct Bigint Bigint; -#ifndef Py_USING_MEMORY_DEBUGGER /* Memory management: memory is allocated from, and returned to, Kmax+1 pools of memory, where pool k (0 <= k <= Kmax) is for Bigints b with b->maxwds == @@ -399,47 +398,6 @@ Bfree(Bigint *v) } } -#else - -/* Alternative versions of Balloc and Bfree that use PyMem_Malloc and - PyMem_Free directly in place of the custom memory allocation scheme above. - These are provided for the benefit of memory debugging tools like - Valgrind. */ - -/* Allocate space for a Bigint with up to 1<k = k; - rv->maxwds = x; - rv->sign = rv->wds = 0; - return rv; -} - -/* Free a Bigint allocated with Balloc */ - -static void -Bfree(Bigint *v) -{ - if (v) { - FREE((void*)v); - } -} - -#endif /* Py_USING_MEMORY_DEBUGGER */ #define Bcopy(x,y) memcpy((char *)&x->sign, (char *)&y->sign, \ y->wds*sizeof(Long) + 2*sizeof(int)) @@ -675,8 +633,6 @@ mult(Bigint *a, Bigint *b) return c; } -#ifndef Py_USING_MEMORY_DEBUGGER - /* p5s is a linked list of powers of 5 of the form 5**(2**i), i >= 2 */ static Bigint *p5s; @@ -736,58 +692,6 @@ pow5mult(Bigint *b, int k) return b; } -#else - -/* Version of pow5mult that doesn't cache powers of 5. Provided for - the benefit of memory debugging tools like Valgrind. */ - -static Bigint * -pow5mult(Bigint *b, int k) -{ - Bigint *b1, *p5, *p51; - int i; - static const int p05[3] = { 5, 25, 125 }; - - if ((i = k & 3)) { - b = multadd(b, p05[i-1], 0); - if (b == NULL) - return NULL; - } - - if (!(k >>= 2)) - return b; - p5 = i2b(625); - if (p5 == NULL) { - Bfree(b); - return NULL; - } - - for(;;) { - if (k & 1) { - b1 = mult(b, p5); - Bfree(b); - b = b1; - if (b == NULL) { - Bfree(p5); - return NULL; - } - } - if (!(k >>= 1)) - break; - p51 = mult(p5, p5); - Bfree(p5); - p5 = p51; - if (p5 == NULL) { - Bfree(b); - return NULL; - } - } - Bfree(p5); - return b; -} - -#endif /* Py_USING_MEMORY_DEBUGGER */ - /* shift a Bigint b left by k bits. Return a pointer to the shifted result, or NULL on failure. If the returned pointer is distinct from b then the original b will have been Bfree'd. Ignores the sign of b. */ From 8436e83b2e94702b9f9fb062bd02188a02acf0c5 Mon Sep 17 00:00:00 2001 From: Felipe Rodrigues Date: Tue, 14 Sep 2021 10:10:07 -0300 Subject: [PATCH 3/8] Update valgrind-python.supp --- Misc/valgrind-python.supp | 3 --- 1 file changed, 3 deletions(-) diff --git a/Misc/valgrind-python.supp b/Misc/valgrind-python.supp index 295ae382ee7a9f..3a777c660a72cf 100644 --- a/Misc/valgrind-python.supp +++ b/Misc/valgrind-python.supp @@ -7,9 +7,6 @@ # valgrind --tool=memcheck --suppressions=Misc/valgrind-python.supp \ # ./python -E ./Lib/test/regrtest.py -u gui,network # -# You must edit Objects/obmalloc.c to use the preferred -# suppressions with address_in_range. -# # If you do not want to recompile Python, you can uncomment # suppressions for _PyObject_Free and _PyObject_Realloc. # From 60cde7b1ef5d8968463acdd29c134586c771407f Mon Sep 17 00:00:00 2001 From: Oleg Iarygin Date: Sun, 12 Feb 2023 22:12:10 +0400 Subject: [PATCH 4/8] Use GitHub Actions version of Bedevere --- .github/workflows/trigger-bots.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/trigger-bots.yml diff --git a/.github/workflows/trigger-bots.yml b/.github/workflows/trigger-bots.yml new file mode 100644 index 00000000000000..995ca2658bf173 --- /dev/null +++ b/.github/workflows/trigger-bots.yml @@ -0,0 +1,20 @@ +name: Bots + +on: + # PR synchronization is a push into a branch associated with the PR + pull_request: + types: [opened, edited, synchronize, labeled, unlabeled] + issue_comment: + types: [created, edited] + pull_request_review_comment: + types: [created, edited] + +jobs: + call_bedevere: + name: Call Bedevere + runs-on: ubuntu-latest + steps: + - uses: arhadthedev/bedevere@c51d1d2d5c7a9cec31ce16af209f42a5905070dd + with: + token: ${{ secrets.BEDEVERE_PAT }} + event: ${{ toJSON(github.event) }} From 2f695340ccfca504ed509655f10c838e33d8e954 Mon Sep 17 00:00:00 2001 From: Oleg Iarygin Date: Mon, 13 Feb 2023 20:32:50 +0400 Subject: [PATCH 5/8] Clean up remains of Py_USING_MEMORY_DEBUGGER --- Include/internal/pycore_dtoa.h | 11 --------- Python/dtoa.c | 42 ---------------------------------- 2 files changed, 53 deletions(-) diff --git a/Include/internal/pycore_dtoa.h b/Include/internal/pycore_dtoa.h index 67189cf0ade665..b93931b020431f 100644 --- a/Include/internal/pycore_dtoa.h +++ b/Include/internal/pycore_dtoa.h @@ -22,15 +22,6 @@ Bigint { ULong x[1]; }; -#ifdef Py_USING_MEMORY_DEBUGGER - -struct _dtoa_runtime_state { - int _not_used; -}; -#define _dtoa_runtime_state_INIT {0} - -#else // !Py_USING_MEMORY_DEBUGGER - /* The size of the Bigint freelist */ #define Bigint_Kmax 7 @@ -53,8 +44,6 @@ struct _dtoa_runtime_state { .preallocated_next = runtime.dtoa.preallocated, \ } -#endif // !Py_USING_MEMORY_DEBUGGER - /* These functions are used by modules compiled as C extension like math: they must be exported. */ diff --git a/Python/dtoa.c b/Python/dtoa.c index 423b24046a4bf2..df1eff8e1a544a 100644 --- a/Python/dtoa.c +++ b/Python/dtoa.c @@ -394,48 +394,6 @@ Bfree(Bigint *v) #undef private_mem #undef freelist -#else - -/* Alternative versions of Balloc and Bfree that use PyMem_Malloc and - PyMem_Free directly in place of the custom memory allocation scheme above. - These are provided for the benefit of memory debugging tools like - Valgrind. */ - -/* Allocate space for a Bigint with up to 1<k = k; - rv->maxwds = x; - rv->sign = rv->wds = 0; - return rv; -} - -/* Free a Bigint allocated with Balloc */ - -static void -Bfree(Bigint *v) -{ - if (v) { - FREE((void*)v); - } -} - -#endif /* Py_USING_MEMORY_DEBUGGER */ - #define Bcopy(x,y) memcpy((char *)&x->sign, (char *)&y->sign, \ y->wds*sizeof(Long) + 2*sizeof(int)) From 850fdefa52f39b9b2b797c7142d02841055922b8 Mon Sep 17 00:00:00 2001 From: Oleg Iarygin Date: Mon, 13 Feb 2023 20:36:24 +0400 Subject: [PATCH 6/8] Remove an accidentally added file --- .github/workflows/trigger-bots.yml | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 .github/workflows/trigger-bots.yml diff --git a/.github/workflows/trigger-bots.yml b/.github/workflows/trigger-bots.yml deleted file mode 100644 index 995ca2658bf173..00000000000000 --- a/.github/workflows/trigger-bots.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Bots - -on: - # PR synchronization is a push into a branch associated with the PR - pull_request: - types: [opened, edited, synchronize, labeled, unlabeled] - issue_comment: - types: [created, edited] - pull_request_review_comment: - types: [created, edited] - -jobs: - call_bedevere: - name: Call Bedevere - runs-on: ubuntu-latest - steps: - - uses: arhadthedev/bedevere@c51d1d2d5c7a9cec31ce16af209f42a5905070dd - with: - token: ${{ secrets.BEDEVERE_PAT }} - event: ${{ toJSON(github.event) }} From eef698a3a4191d5a56a1baf40c6cdc296b147071 Mon Sep 17 00:00:00 2001 From: Oleg Iarygin Date: Mon, 13 Feb 2023 20:38:13 +0400 Subject: [PATCH 7/8] Fix merge errors --- Python/dtoa.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/Python/dtoa.c b/Python/dtoa.c index df1eff8e1a544a..d56a79c1b6d9f5 100644 --- a/Python/dtoa.c +++ b/Python/dtoa.c @@ -628,9 +628,6 @@ mult(Bigint *a, Bigint *b) return c; } -/* p5s is a linked list of powers of 5 of the form 5**(2**i), i >= 2 */ - -static Bigint *p5s; /* multiply the Bigint b by 5**k. Returns a pointer to the result, or NULL on failure; if the returned pointer is distinct from b then the original From d200029cd6524542f6c843e93bb0496e23dfc928 Mon Sep 17 00:00:00 2001 From: Oleg Iarygin Date: Mon, 13 Feb 2023 20:48:03 +0400 Subject: [PATCH 8/8] Add a news entry --- .../2023-02-13-20-47-40.gh-issue-88929.gK8DdS.rst | 2 ++ Python/dtoa.c | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2023-02-13-20-47-40.gh-issue-88929.gK8DdS.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-02-13-20-47-40.gh-issue-88929.gK8DdS.rst b/Misc/NEWS.d/next/Core and Builtins/2023-02-13-20-47-40.gh-issue-88929.gK8DdS.rst new file mode 100644 index 00000000000000..70d5966d13b4d0 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2023-02-13-20-47-40.gh-issue-88929.gK8DdS.rst @@ -0,0 +1,2 @@ +Remove the last place where the previously removed macro +``Py_USING_MEMORY_DEBUGGER`` is checked. Patch by Felipe Rodrigues. diff --git a/Python/dtoa.c b/Python/dtoa.c index d56a79c1b6d9f5..ec1f15cae7a3be 100644 --- a/Python/dtoa.c +++ b/Python/dtoa.c @@ -628,7 +628,6 @@ mult(Bigint *a, Bigint *b) return c; } - /* multiply the Bigint b by 5**k. Returns a pointer to the result, or NULL on failure; if the returned pointer is distinct from b then the original Bigint b will have been Bfree'd. Ignores the sign of b. */