Tarantool development patches archive
 help / color / mirror / Atom feed
From: Sergey Kaplun via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Evgeniy Temirgaleev <e.temirgaleev@tarantool.org>,
	Sergey Bronnikov <sergeyb@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH luajit 2/2] x64: Fix math.floor()/ceil() argument check.
Date: Mon, 23 Nov 2026 13:46:01 +0300	[thread overview]
Message-ID: <7939469a9c9e06c7728a87addcd2bdf4efb56807.1795430601.git.skaplun@tarantool.org> (raw)
In-Reply-To: <cover.1795430601.git.skaplun@tarantool.org>

From: Mike Pall <mike>

Thanks to RaphaelIT7.

(cherry picked from commit 849bbbe763e38080ae7ec6bd9b2be34156ec6b80)

The `math.floor()`, `math.ceil()` VM implementation uses the `.ffunc`
macro, which doesn't check the given arguments. If the top stack value
contains some garbage number value, it will be used as the function
result instead of raising an error.

This patch fixes the behaviour for GC64 mode by using the correct
`.ffunc_1` macro. The test is the same as for the non-GC64 mode.

Sergey Kaplun:
* added the description for the problem

Part of tarantool/tarantool#13442
---
 src/vm_x64.dasc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/vm_x64.dasc b/src/vm_x64.dasc
index 2eb4d752..e17f84e9 100644
--- a/src/vm_x64.dasc
+++ b/src/vm_x64.dasc
@@ -1798,7 +1798,7 @@ static void build_subroutines(BuildCtx *ctx)
   |  jmp ->vm_return
   |
   |.macro math_round, func
-  |  .ffunc math_ .. func
+  |  .ffunc_1 math_ .. func
   |.if DUALNUM
   |  mov RB, [BASE]
   |  checknumx RB, ->fff_resRB, je
-- 
2.56.0


      parent reply	other threads:[~2026-11-23 10:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 10:45 [Tarantool-patches] [PATCH luajit 0/2] " Sergey Kaplun via Tarantool-patches
2026-11-23 10:46 ` [Tarantool-patches] [PATCH luajit 1/2] x86: " Sergey Kaplun via Tarantool-patches
2026-11-23 10:46 ` Sergey Kaplun via Tarantool-patches [this message]

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=7939469a9c9e06c7728a87addcd2bdf4efb56807.1795430601.git.skaplun@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=e.temirgaleev@tarantool.org \
    --cc=sergeyb@tarantool.org \
    --cc=skaplun@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH luajit 2/2] x64: Fix math.floor()/ceil() argument check.' \
    /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