From: "Георгий Кириченко" <georgy@tarantool.org>
To: tarantool-patches@freelists.org
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Subject: [tarantool-patches] Re: [PATCH v2] lua/fiber: Fix abort on malformed join input
Date: Sat, 23 Feb 2019 22:49:02 +0300 [thread overview]
Message-ID: <14237938.h0nRFiLebg@home.lan> (raw)
In-Reply-To: <20190223133442.GC7198@uranus>
[-- Attachment #1: Type: text/plain, Size: 2408 bytes --]
Looks good for me, thanks
On Saturday, February 23, 2019 4:34:42 PM MSK Cyrill Gorcunov wrote:
> If I create a new fiber and the join to himself we get an abort:
> | tarantool> f = require('fiber')
> | ---
> | ...
> |
> | tarantool> f.join(f.self())
> | tarantool: src/fiber.c:407: fiber_join: Assertion `fiber->flags &
> | FIBER_IS_JOINABLE' failed. Aborted (core dumped)
>
> we should better throw an error.
>
> v2: by georgy@
> - add a testcase
>
> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
> ---
> src/lua/fiber.c | 6 +++++-
> test/app/fiber.result | 11 +++++++++++
> test/app/fiber.test.lua | 7 +++++++
> 3 files changed, 23 insertions(+), 1 deletion(-)
>
> Index: tarantool.git/src/lua/fiber.c
> ===================================================================
> --- tarantool.git.orig/src/lua/fiber.c
> +++ tarantool.git/src/lua/fiber.c
> @@ -676,10 +676,14 @@ lbox_fiber_join(struct lua_State *L)
> {
> struct fiber *fiber = lbox_checkfiber(L, 1);
> struct lua_State *child_L = fiber->storage.lua.stack;
> - fiber_join(fiber);
> struct error *e = NULL;
> int num_ret = 0;
> int coro_ref = 0;
> +
> + if (!(fiber->flags & FIBER_IS_JOINABLE))
> + luaL_error(L, "the fiber is not joinable");
> + fiber_join(fiber);
> +
> if (child_L != NULL) {
> coro_ref = lua_tointeger(child_L, -1);
> lua_pop(child_L, 1);
> Index: tarantool.git/test/app/fiber.result
> ===================================================================
> --- tarantool.git.orig/test/app/fiber.result
> +++ tarantool.git/test/app/fiber.result
> @@ -1454,6 +1454,17 @@ ch1:put(1)
> while f:status() ~= 'dead' do fiber.sleep(0.01) end
> ---
> ...
> +--
> +-- Test if fiber join() does not crash
> +-- if unjoinable
> +--
> +fj = require('fiber')
> +---
> +...
> +fj.join(fj.self())
> +---
> +- error: the fiber is not joinable
> +...
> -- cleanup
> test_run:cmd("clear filter")
> ---
> Index: tarantool.git/test/app/fiber.test.lua
> ===================================================================
> --- tarantool.git.orig/test/app/fiber.test.lua
> +++ tarantool.git/test/app/fiber.test.lua
> @@ -623,6 +623,13 @@ ch1:put(1)
>
> while f:status() ~= 'dead' do fiber.sleep(0.01) end
>
> +--
> +-- Test if fiber join() does not crash
> +-- if unjoinable
> +--
> +fj = require('fiber')
> +fj.join(fj.self())
> +
> -- cleanup
> test_run:cmd("clear filter")
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2019-02-23 19:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-23 13:34 [tarantool-patches] " Cyrill Gorcunov
2019-02-23 19:49 ` Георгий Кириченко [this message]
2019-02-25 12:54 ` Vladimir Davydov
2019-02-25 13:12 ` Cyrill Gorcunov
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=14237938.h0nRFiLebg@home.lan \
--to=georgy@tarantool.org \
--cc=gorcunov@gmail.com \
--cc=tarantool-patches@freelists.org \
--subject='[tarantool-patches] Re: [PATCH v2] lua/fiber: Fix abort on malformed join input' \
/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