From: Sergey Kaplun via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Sergey Bronnikov <sergeyb@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH luajit 1/2] Fix pointer check for non-GC64 mode.
Date: Mon, 2 Mar 2026 11:05:31 +0300 [thread overview]
Message-ID: <07878e492b55e0fb788ff7b037c0a7bc1073934a.1772438261.git.skaplun@tarantool.org> (raw)
In-Reply-To: <cover.1772438261.git.skaplun@tarantool.org>
From: Mike Pall <mike>
Thanks to Stefan Hett.
(cherry picked from commit 471f8936cbd6aa80a937e375fe53ecadab93696a)
This commit fixes the check for the pointer returned by the internal
LuaJIT allocator. For non-GC64 mode, the accessible address range should
fit in 31 bits due to VM (and JIT) restrictions. This commit fixes the
check.
Since it is just an assertion check, there are no tests added for the
change. But this commit simplifies the reproducer for the next patch
(although not required).
Sergey Kaplun:
* added the description for the problem
Part of tarantool/tarantool#12134
---
src/lj_def.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/lj_def.h b/src/lj_def.h
index a5bca6b0..b06462fe 100644
--- a/src/lj_def.h
+++ b/src/lj_def.h
@@ -105,9 +105,10 @@ typedef unsigned int uintptr_t;
#define checku16(x) ((x) == (int32_t)(uint16_t)(x))
#define checki32(x) ((x) == (int32_t)(x))
#define checku32(x) ((x) == (uint32_t)(x))
+#define checkptr31(x) (((uint64_t)(uintptr_t)(x) >> 31) == 0)
#define checkptr32(x) ((uintptr_t)(x) == (uint32_t)(uintptr_t)(x))
#define checkptr47(x) (((uint64_t)(uintptr_t)(x) >> 47) == 0)
-#define checkptrGC(x) (LJ_GC64 ? checkptr47((x)) : LJ_64 ? checkptr32((x)) :1)
+#define checkptrGC(x) (LJ_GC64 ? checkptr47((x)) : LJ_64 ? checkptr31((x)) :1)
/* Every half-decent C compiler transforms this into a rotate instruction. */
#define lj_rol(x, n) (((x)<<(n)) | ((x)>>(-(int)(n)&(8*sizeof(x)-1))))
--
2.53.0
next prev parent reply other threads:[~2026-03-02 8:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-02 8:05 [Tarantool-patches] [PATCH luajit 0/2] Correct allocation limit without JIT Sergey Kaplun via Tarantool-patches
2026-03-02 8:05 ` Sergey Kaplun via Tarantool-patches [this message]
2026-03-02 8:05 ` [Tarantool-patches] [PATCH luajit 2/2] x64/!LJ_GC64: The allocation limit is required for a no-JIT build, too Sergey Kaplun via Tarantool-patches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=07878e492b55e0fb788ff7b037c0a7bc1073934a.1772438261.git.skaplun@tarantool.org \
--to=tarantool-patches@dev.tarantool.org \
--cc=sergeyb@tarantool.org \
--cc=skaplun@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH luajit 1/2] Fix pointer check for non-GC64 mode.' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox