]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-126881: fix finalization of dtoa state (GH-126904) (#127395)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 29 Nov 2024 10:52:21 +0000 (11:52 +0100)
committerGitHub <noreply@github.com>
Fri, 29 Nov 2024 10:52:21 +0000 (10:52 +0000)
gh-126881: fix finalization of dtoa state (GH-126904)
(cherry picked from commit 762c603a866146afc7db2591fb49605e0858e9b1)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Misc/NEWS.d/next/Core_and_Builtins/2024-11-16-11-11-35.gh-issue-126881.ijofLZ.rst [new file with mode: 0644]
Python/pylifecycle.c

diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2024-11-16-11-11-35.gh-issue-126881.ijofLZ.rst b/Misc/NEWS.d/next/Core_and_Builtins/2024-11-16-11-11-35.gh-issue-126881.ijofLZ.rst
new file mode 100644 (file)
index 0000000..13381c7
--- /dev/null
@@ -0,0 +1 @@
+Fix crash in finalization of dtoa state. Patch by Kumar Aditya.
index 0cd4fb417636a211ed7abb8d09e37a018b2befb3..8fe5bb8b3007d901f04f61eb573fa1dc4aeedc30 100644 (file)
@@ -1869,7 +1869,6 @@ finalize_interp_clear(PyThreadState *tstate)
     _PyXI_Fini(tstate->interp);
     _PyExc_ClearExceptionGroupType(tstate->interp);
     _Py_clear_generic_types(tstate->interp);
-    _PyDtoa_Fini(tstate->interp);
 
     /* Clear interpreter state and all thread states */
     _PyInterpreterState_Clear(tstate);
@@ -1891,6 +1890,9 @@ finalize_interp_clear(PyThreadState *tstate)
 
     finalize_interp_types(tstate->interp);
 
+    /* Finalize dtoa at last so that finalizers calling repr of float doesn't crash */
+    _PyDtoa_Fini(tstate->interp);
+
     /* Free any delayed free requests immediately */
     _PyMem_FiniDelayed(tstate->interp);