Tarantool development patches archive
 help / color / mirror / Atom feed
From: Sergey Kaplun via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Sergey Bronnikov <estetus@gmail.com>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH luajit] Fix compilation of getmetatable() for UDTYPE_IO_FILE
Date: Tue, 12 Nov 2024 22:23:20 +0300	[thread overview]
Message-ID: <ZzOrKAKgndu9eeFv@root> (raw)
In-Reply-To: <76c9c163c365aec70741162ab83fdfa6385a9118.1730976041.git.sergeyb@tarantool.org>

Hi, Sergey!
Thanks for the patch!
Nice catch!

Please, consider my comments below.

On 07.11.24, Sergey Bronnikov wrote:
> From: Sergey Bronnikov <sergeyb@tarantool.org>
> 
> The patch fixes a problem with recording `getmetatable()`
> for I/O object: recording of `getmetatable` call with a file

Typo: s<I/O><an I/O>
Typo: s/recording of/recording the/
Typo: s/a file/file/

> descriptors represented by userdata object `UDTYPE_IO_FILE`
> (like `io.stdout`) leads to violation of assertion in
> `rec_check_slots`.

Nit:
| ... by the userdata object `UDTYPE_IO_FILE` (like `io.stdout`) always
| stores `nil` instead of the given metatable. This leads to the
| violation of the assertion in `rec_check_slots`.

> 
> Note, the problem was fixed upstream in different manner, see
> commit 5141cbc20c43

Nit: Please, use full commit hash.

Also, please describe that specialized recording (introduced in the
upstream) lacks the check of the metatable precense. So, the fix in
upstream is incomplete (according to the comment [1]).

Also, please add both testcases from the issue comment [1] (don't forget
to restore metatable after the first of them).

> ("Fix compiliation of getmetatable() for UDTYPE_IO_FILE.").
> ---
>  src/lj_record.c                               |  2 +-
>  ...-incorrect-recording-getmetatable.test.lua | 21 +++++++++++++++++++
>  2 files changed, 22 insertions(+), 1 deletion(-)
>  create mode 100644 test/tarantool-tests/lj-1279-incorrect-recording-getmetatable.test.lua
> 
> diff --git a/src/lj_record.c b/src/lj_record.c
> index cc97bdf9..7181b72a 100644
> --- a/src/lj_record.c
> +++ b/src/lj_record.c

<snipped>

> diff --git a/test/tarantool-tests/lj-1279-incorrect-recording-getmetatable.test.lua b/test/tarantool-tests/lj-1279-incorrect-recording-getmetatable.test.lua
> new file mode 100644
> index 00000000..8bf22ca7
> --- /dev/null
> +++ b/test/tarantool-tests/lj-1279-incorrect-recording-getmetatable.test.lua
> @@ -0,0 +1,21 @@
> +local tap = require('tap')
> +
> +local test = tap.test('lj-1279-incorrect-recording-getmetatable')
> +test:plan(1)
> +
> +-- A test file to demonstrate an incorrect recording of
> +-- getmetatable() for I/O handlers.
> +-- https://github.com/LuaJIT/LuaJIT/issues/1279

Nit: Usually the link is right before `tap.test()` declaration.

> +
> +jit.opt.start("hotloop=1")

Nit: Please use single quotes.

> +
> +local obj = io.stdout

Minor: I would rather name the variable like the corresponding type --
`ud_io_file`. Feel free to ignore.

> +local getmetatable = getmetatable
> +
> +for _ = 1, 4 do
> +  _ = getmetatable(obj)
> +end
> +
> +test:ok(true, 'getmetatable() recording is correct')

Let's check the resulted metatable too. (We can use `test:samevalues()`
here, for example.)

> +
> +test:done(true)
> -- 
> 2.34.1
> 

[1]: https://github.com/LuaJIT/LuaJIT/issues/1279#issuecomment-2382392847

-- 
Best regards,
Sergey Kaplun

      parent reply	other threads:[~2024-11-12 19:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-07 10:51 Sergey Bronnikov via Tarantool-patches
2024-11-07 14:37 ` Sergey Bronnikov via Tarantool-patches
2024-11-12 19:23 ` 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=ZzOrKAKgndu9eeFv@root \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=estetus@gmail.com \
    --cc=skaplun@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH luajit] Fix compilation of getmetatable() for UDTYPE_IO_FILE' \
    /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