Tarantool development patches archive
 help / color / mirror / Atom feed
From: Igor Munkin <imun@tarantool.org>
To: Ilya Kosarev <i.kosarev@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH v3] lua: assert in lua_gettop() in case of negative stack size
Date: Wed, 22 Jul 2020 13:47:25 +0300	[thread overview]
Message-ID: <20200722104725.GM18920@tarantool.org> (raw)
In-Reply-To: <1595413507.397395465@f430.i.mail.ru>

I'll add more info for Nikita and Sergos since they are also involved
to the investigation and the patch review.

On 22.07.20, Ilya Kosarev wrote:
> 
> Right, error fixed and now we found more details.

Here are the details:
| (gdb) p ((struct port_lua *)&port)->L
| $1 = (lua_State *) 0x41b8fa08
| (gdb) p ((struct port_lua *)&port)
| $2 = (port_lua *) 0x7ef54107fe30
| (gdb) p ((struct port_lua *)&port)->vtab
| $3 = (const port_vtab *) 0x708d60 <port_lua_vtab>
| (gdb) p ((struct port_lua *)&port)->ref
| $4 = 181

port->ref value is rotten since port->L is removed from Lua registry
within <port_destroy> (i.e. <port_lua_destroy>) function. But the
pointer to port->L is fine.

| (gdb) p ((struct port_lua *)&port)->size
| $5 = -1

size value is initialized to -1 prior to encoding loop, so there is no
<luamp_encode> call.

| (gdb) p ((struct port_lua *)&port)->out
| $6 = (obuf *) 0x7f00098692e8
| (gdb) p ((struct port_lua *)&port)->L->top
| $7 = (TValue *) 0x4107fa08
| (gdb) p ((struct port_lua *)&port)->L->base
| $8 = (TValue *) 0x4107fa10

size value is initialized properly since L->base is greater than L->top
(guest stack addresses grow downwards). Oops...

> Now the best assumption is that lua_State is somehow being broken by
> user-called function (which name we now know).

The port (and ergo port->L coroutine) is created in scope of
<box_process_lua> call. Considering the message type (IPROTO_CALL)
<execute_lua_call> handler is called. Both Ilya and me found nothing
suspicious there: the function to be called is found by its name and
then execution enters Lua space.

Considering the results (<box_process_call> rc is 0) the call succeeds
and execution proceeds with reply packing. There is also nothing
corrupting port->L coroutine internal structure prior to the place
port->size is initialized to -1.

> Now we will look into user code.

For now I see no reason to add even the assert, since Ilya's assumptions
are confirmed.


<snipped>

>  
> --
> Ilya Kosarev
>  

-- 
Best regards,
IM

  reply	other threads:[~2020-07-22 10:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-21 22:32 Ilya Kosarev
2020-07-22  8:59 ` Nikita Pettik
2020-07-22  9:46   ` Ilya Kosarev
2020-07-22  9:46     ` Igor Munkin
2020-07-22 10:25       ` Ilya Kosarev
2020-07-22 10:47         ` Igor Munkin [this message]
2020-07-22 11:08           ` Nikita Pettik
2020-07-22 12:05             ` Igor Munkin

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=20200722104725.GM18920@tarantool.org \
    --to=imun@tarantool.org \
    --cc=i.kosarev@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v3] lua: assert in lua_gettop() in case of negative stack size' \
    /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