From 32c0316afe21b77f0b3bb40728776405d3ee7d76 Mon Sep 17 00:00:00 2001 From: Aapo Talvensaari Date: Mon, 17 Jun 2024 13:11:55 +0300 Subject: [PATCH] chore(patches): fix luajit segment release check in internal memory allocator ### Summary See: https://github.com/LuaJIT/LuaJIT/commit/9b5e837ac2dfdc0638830c048a47ca9378c504d3 Signed-off-by: Aapo Talvensaari --- ...LuaJIT-2.1-20231117_03_fix-segment-release.patch | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 build/openresty/patches/LuaJIT-2.1-20231117_03_fix-segment-release.patch diff --git a/build/openresty/patches/LuaJIT-2.1-20231117_03_fix-segment-release.patch b/build/openresty/patches/LuaJIT-2.1-20231117_03_fix-segment-release.patch new file mode 100644 index 000000000000..7a24819a3773 --- /dev/null +++ b/build/openresty/patches/LuaJIT-2.1-20231117_03_fix-segment-release.patch @@ -0,0 +1,13 @@ +diff --git a/bundle/LuaJIT-2.1-20231117/src/lj_alloc.c b/bundle/LuaJIT-2.1-20231117/src/lj_alloc.c +index 9adaa0e5bd..0c0c0c4f4c 100644 +--- a/bundle/LuaJIT-2.1-20231117/src/lj_alloc.c ++++ b/bundle/LuaJIT-2.1-20231117/src/lj_alloc.c +@@ -1057,7 +1057,7 @@ static size_t release_unused_segments(mstate m) + mchunkptr p = align_as_chunk(base); + size_t psize = chunksize(p); + /* Can unmap if first chunk holds entire segment and not pinned */ +- if (!cinuse(p) && (char *)p + psize >= base + size - TOP_FOOT_SIZE) { ++ if (!cinuse(p) && (char *)p + psize == (char *)mem2chunk(sp)) { + tchunkptr tp = (tchunkptr)p; + if (p == m->dv) { + m->dv = 0;