Tarantool development patches archive
 help / color / mirror / Atom feed
From: Sergey Bronnikov via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Maksim Kokryashkin <max.kokryashkin@gmail.com>,
	tarantool-patches@dev.tarantool.org, skaplun@tarantool.org,
	m.kokryashkin@tarantool.org
Subject: Re: [Tarantool-patches] [PATCH luajit v2 2/2] Fix last commit.
Date: Thu, 9 Nov 2023 15:08:48 +0300	[thread overview]
Message-ID: <4b9160db-32f4-4edd-ae1c-39a7cf004216@tarantool.org> (raw)
In-Reply-To: <20231107210616.53138-3-max.kokryashkin@gmail.com>

Hi, Max

Thanks for the patch! LGTM


On 11/8/23 00:06, Maksim Kokryashkin wrote:
> From: Mike Pall <mike>
>
> Reported by PluMGMK.
>
> (cherry-picked from commit 224129a8e64bfa219d35cd03055bf03952f167f6)
>
> The `_VMEVENTS` table, where the error handler for GC finalizers
> is set, was not cleared from the stack after the initialization.
> This commit adds stack cleanup.
>
> Maxim Kokryashkin:
> * added the description and the test for the problem
>
> Part of tarantool/tarantool#9145
> ---
>   src/lib_aux.c                                 |  2 ++
>   ...91-fix-finalizer-error-handler-init.test.c | 30 +++++++++++++++++++
>   2 files changed, 32 insertions(+)
>   create mode 100644 test/tarantool-c-tests/lj-991-fix-finalizer-error-handler-init.test.c
>
> diff --git a/src/lib_aux.c b/src/lib_aux.c
> index d532a12f..ecdc67f9 100644
> --- a/src/lib_aux.c
> +++ b/src/lib_aux.c
> @@ -352,6 +352,7 @@ LUALIB_API lua_State *luaL_newstate(void)
>       lua_pushcfunction(L, error_finalizer);
>       lua_rawseti(L, -2, VMEVENT_HASH(LJ_VMEVENT_ERRFIN));
>       G(L)->vmevmask = VMEVENT_MASK(LJ_VMEVENT_ERRFIN);
> +    L->top--;
>   #endif
>     }
>     return L;
> @@ -378,6 +379,7 @@ LUALIB_API lua_State *luaL_newstate(void)
>       lua_pushcfunction(L, error_finalizer);
>       lua_rawseti(L, -2, VMEVENT_HASH(LJ_VMEVENT_ERRFIN));
>       G(L)->vmevmask = VMEVENT_MASK(LJ_VMEVENT_ERRFIN);
> +    L->top--;
>   #endif
>     }
>     return L;
> diff --git a/test/tarantool-c-tests/lj-991-fix-finalizer-error-handler-init.test.c b/test/tarantool-c-tests/lj-991-fix-finalizer-error-handler-init.test.c
> new file mode 100644
> index 00000000..49befc29
> --- /dev/null
> +++ b/test/tarantool-c-tests/lj-991-fix-finalizer-error-handler-init.test.c
> @@ -0,0 +1,30 @@
> +#include "lua.h"
> +#include "test.h"
> +#include "utils.h"
> +
> +/*
> + * This test demonstrates an uncleared Lua stack after the
> + * initialization of the error handler for GC finalizers.
> + * See https://github.com/luajit/luajit/issues/991 for
> + * details.
> + */
> +
> +static int stack_is_clean(void *test_state)
> +{
> +	lua_State *L = test_state;
> +  assert_true(lua_gettop(L) == 0);
> +	return TEST_EXIT_SUCCESS;
> +}
> +
> +int main(void)
> +{
> +	lua_State *L = utils_lua_init();
> +
> +	const struct test_unit tgroup[] = {
> +		test_unit_def(stack_is_clean)
> +	};
> +
> +	const int test_result = test_run_group(tgroup, L);
> +	utils_lua_close(L);
> +	return test_result;
> +}

  parent reply	other threads:[~2023-11-09 12:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-07 21:06 [Tarantool-patches] [PATCH luajit v2 0/2] gc: handle errors in finalizers Maksim Kokryashkin via Tarantool-patches
2023-11-07 21:06 ` [Tarantool-patches] [PATCH luajit v2 1/2] Print errors from __gc finalizers instead of rethrowing them Maksim Kokryashkin via Tarantool-patches
2023-11-08  8:21   ` Sergey Kaplun via Tarantool-patches
2023-11-09  0:03     ` Maxim Kokryashkin via Tarantool-patches
2023-11-09 12:03   ` Sergey Bronnikov via Tarantool-patches
2023-11-09 12:14     ` Maxim Kokryashkin via Tarantool-patches
2023-11-09 13:14       ` Sergey Bronnikov via Tarantool-patches
2023-11-07 21:06 ` [Tarantool-patches] [PATCH luajit v2 2/2] Fix last commit Maksim Kokryashkin via Tarantool-patches
2023-11-08  8:37   ` Sergey Kaplun via Tarantool-patches
2023-11-09  0:04     ` Maxim Kokryashkin via Tarantool-patches
2023-11-09 12:08   ` Sergey Bronnikov via Tarantool-patches [this message]
2023-11-23  6:30 ` [Tarantool-patches] [PATCH luajit v2 0/2] gc: handle errors in finalizers 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=4b9160db-32f4-4edd-ae1c-39a7cf004216@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=m.kokryashkin@tarantool.org \
    --cc=max.kokryashkin@gmail.com \
    --cc=sergeyb@tarantool.org \
    --cc=skaplun@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH luajit v2 2/2] Fix last commit.' \
    /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