From 6048c570885093376eaa703d699afecfd8e24f53 Mon Sep 17 00:00:00 2001 From: Neil Schemenauer Date: Mon, 18 Oct 2021 22:40:40 -0700 Subject: [PATCH] Fix a bug in the obmalloc radix tree code. MAP_BOT_LENGTH was incorrectly used to compute MAP_TOP_MASK instead of MAP_TOP_LENGTH. On 64-bit machines, the error causes the tree to hold 46-bits of virtual addresses, rather than the intended 48-bits. --- .../Core and Builtins/2021-10-18-22-40-33.bpo-45521.GdMiuW.rst | 3 +++ Objects/obmalloc.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2021-10-18-22-40-33.bpo-45521.GdMiuW.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2021-10-18-22-40-33.bpo-45521.GdMiuW.rst b/Misc/NEWS.d/next/Core and Builtins/2021-10-18-22-40-33.bpo-45521.GdMiuW.rst new file mode 100644 index 00000000000000..3a082a4ffdbcb1 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2021-10-18-22-40-33.bpo-45521.GdMiuW.rst @@ -0,0 +1,3 @@ +Fix a bug in the obmalloc radix tree code. On 64-bit machines, the bug +causes the tree to hold 46-bits of virtual addresses, rather than the +intended 48-bits. diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c index d8d6f6dea0d532..2eddb2cafd4983 100644 --- a/Objects/obmalloc.c +++ b/Objects/obmalloc.c @@ -1341,7 +1341,7 @@ _Py_GetAllocatedBlocks(void) #define MAP_TOP_BITS INTERIOR_BITS #define MAP_TOP_LENGTH (1 << MAP_TOP_BITS) -#define MAP_TOP_MASK (MAP_BOT_LENGTH - 1) +#define MAP_TOP_MASK (MAP_TOP_LENGTH - 1) #define MAP_MID_BITS INTERIOR_BITS #define MAP_MID_LENGTH (1 << MAP_MID_BITS)