Tarantool development patches archive
 help / color / mirror / Atom feed
From: Igor Munkin via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: sergos <sergos@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH luajit 3/3] Avoid conflict between 64 bit lightuserdata and ITERN key.
Date: Wed, 29 Jun 2022 23:20:44 +0300	[thread overview]
Message-ID: <Yry0HNQ4CsN5+g+R@tarantool.org> (raw)
In-Reply-To: <E8B5FDFC-0FEE-4D14-AE5B-2699D5BA342B@tarantool.org>

Sergey,

Thanks for the patch! As a result of the fixes discussed offline, LGTM.

On 20.09.21, sergos wrote:
> Hi!
> 
> > On 20 Sep 2021, at 11:38, Sergey Kaplun <skaplun@tarantool.org> wrote:
> > 
> > Hi, Sergos!
> > 
> > Thanks for the review!
> > 
> > On 15.09.21, sergos wrote:
> 
> [...]
> 
> >>> +++ b/test/tarantool-tests/lj-727-lightuserdata-itern.test.lua
> >>> @@ -0,0 +1,48 @@
> >>> +local tap = require('tap')
> >>> +
> >>> +-- Test file to demonstrate next FF incorrect behaviour on LJ_64.
> >>> +-- See also, https://github.com/LuaJIT/LuaJIT/issues/727.
> >>> +
> >>> +local test = tap.test('lj-727-lightuserdata-itern')
> >>> +test:plan(1)
> >>> +
> >>> +local ud = require('lightuserdata').craft_ptr_wp()
> >>> +
> >>> +-- We now have the tagged lightuuserdata pointer
> >>> +-- 0xFFFE7FFF00000002 in the up before this patch (after the patch
> >>> +-- the maximum available lightuserdata segment is 0xffe).
> >> 
> >> Shall we end the test here with just an expectation of an error?
> >> I believe you can make a way simpler test: pcall(craft_ptr()) should work
> >> successfully 254 times and error on an 255th one, isn’t it?
> > 
> > Not exactly, I think.
> > The main idea of the test -- generate as much lightuserdata objects as
> > we can, and save them in the same table. After that we check that
> > iteration by them is correct.
> > 
> > Test you suggested doesn't show up the possible issue with ITERN, does
> > it?
> 
> Exactly. I don’t see any reason to force the situation showing that you
> can’t use the LUD segment beyond particular value. The test can be that
> simple showing the max segment is 254, not 255 - exactly the functionality
> that is added to the code. So, it should fail at creation of 255th segment
> and it will be the positive outcome of the test. If there’s no error -
> the test fails.
> It will simplify the test considerably. Also, you should not have such
> long explanation of ITERN/ITERC - just say "the 255th segment is forbidden,
> since its encoding is overlapped with control variable used by ISNEXT”.

Sergos, I'm partially agree with you: we can just check that the last
lightuserdata segment is reserved for LuaJIT internal usage -- this is
the case. However, Sergey wants to check that after this patch ITERN
despecialization doesn't lead to table misiteration (since this is the
symptom being reported in LuaJIT queue).

Unfortunately I can't figure out two issues:
1. How to properly check the BADLU is raised for the *last* segment
(consider the comment in the commit from the trunk[1]).
2. What is more important: how does this error stops us from using
"ITERN-magic-range" pointers outside of the last segment? I might be
missing some related macro-magic, but AFAIU a new segment is created for
any lightudup value, hence 0xfffe7fff... pointers can be mapped into the
second segment, can't they?

Anyway, I guess we can proceed with this series and report an issue/PR
to the vanilla trunk when the issue bothers us again.

P.S. What if we create "craft pointers" in a reverse order? I'll check
this a bit later.

> 
> I would recommend to wait for the 2nd reviewer here - especially if you
> discussed the patch before submit.
> 
> Regards,
> Sergos
> 

-- 
Best regards,
IM

  reply	other threads:[~2022-06-29 20:27 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-09  7:03 [Tarantool-patches] [PATCH luajit 0/3] Follow-up fixes for full 64-bit lightuserdata interning Sergey Kaplun via Tarantool-patches
2021-09-09  7:03 ` [Tarantool-patches] [PATCH luajit 1/3] test: fix path storage for non-concatable objects Sergey Kaplun via Tarantool-patches
2021-09-15 15:30   ` sergos via Tarantool-patches
2021-09-20  8:28     ` Sergey Kaplun via Tarantool-patches
2021-09-20  9:37       ` sergos via Tarantool-patches
2022-06-28 15:41   ` Igor Munkin via Tarantool-patches
2021-09-09  7:03 ` [Tarantool-patches] [PATCH luajit 2/3] Reorganize lightuserdata interning code Sergey Kaplun via Tarantool-patches
2021-09-15 15:30   ` sergos via Tarantool-patches
2021-09-20  8:32     ` Sergey Kaplun via Tarantool-patches
2021-09-20  9:37       ` sergos via Tarantool-patches
2022-06-28 15:42   ` Igor Munkin via Tarantool-patches
2021-09-09  7:03 ` [Tarantool-patches] [PATCH luajit 3/3] Avoid conflict between 64 bit lightuserdata and ITERN key Sergey Kaplun via Tarantool-patches
2021-09-15 15:31   ` sergos via Tarantool-patches
2021-09-20  8:38     ` Sergey Kaplun via Tarantool-patches
2021-09-20  9:37       ` sergos via Tarantool-patches
2022-06-29 20:20         ` Igor Munkin via Tarantool-patches [this message]
2022-06-30 12:11 ` [Tarantool-patches] [PATCH luajit 0/3] Follow-up fixes for full 64-bit lightuserdata interning Igor Munkin 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=Yry0HNQ4CsN5+g+R@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=imun@tarantool.org \
    --cc=sergos@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH luajit 3/3] Avoid conflict between 64 bit lightuserdata and ITERN key.' \
    /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