Tarantool development patches archive
 help / color / mirror / Atom feed
* [tarantool-patches] [PATCH] lua,fiber: Fix abort on malformed join input
@ 2019-02-22 19:53 Cyrill Gorcunov
  2019-02-23 12:21 ` [tarantool-patches] " Георгий Кириченко
  0 siblings, 1 reply; 3+ messages in thread
From: Cyrill Gorcunov @ 2019-02-22 19:53 UTC (permalink / raw)
  To: tarantool

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.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 src/lua/fiber.c |    6 +++++-
 1 file changed, 5 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);

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tarantool-patches] Re: [PATCH] lua,fiber: Fix abort on malformed join input
  2019-02-22 19:53 [tarantool-patches] [PATCH] lua,fiber: Fix abort on malformed join input Cyrill Gorcunov
@ 2019-02-23 12:21 ` Георгий Кириченко
  2019-02-23 12:30   ` Cyrill Gorcunov
  0 siblings, 1 reply; 3+ messages in thread
From: Георгий Кириченко @ 2019-02-23 12:21 UTC (permalink / raw)
  To: tarantool-patches; +Cc: Cyrill Gorcunov

[-- Attachment #1: Type: text/plain, Size: 1357 bytes --]

Hi!

The patch looks good for me but could you please add a small test case.
Some examples might be found in test/app/fiber.test.lua file.

On Friday, February 22, 2019 10:53:58 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.
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
> ---
>  src/lua/fiber.c |    6 +++++-
>  1 file changed, 5 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);


[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tarantool-patches] Re: [PATCH] lua,fiber: Fix abort on malformed join input
  2019-02-23 12:21 ` [tarantool-patches] " Георгий Кириченко
@ 2019-02-23 12:30   ` Cyrill Gorcunov
  0 siblings, 0 replies; 3+ messages in thread
From: Cyrill Gorcunov @ 2019-02-23 12:30 UTC (permalink / raw)
  To: Георгий
	Кириченко
  Cc: tarantool-patches

On Sat, Feb 23, 2019 at 03:21:25PM +0300, Георгий Кириченко wrote:
> 
> The patch looks good for me but could you please add a small test case.
> Some examples might be found in test/app/fiber.test.lua file.

Will do, thanks! Need to figure out how to run test engine and
get a bit familar with lua.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-02-23 12:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-22 19:53 [tarantool-patches] [PATCH] lua,fiber: Fix abort on malformed join input Cyrill Gorcunov
2019-02-23 12:21 ` [tarantool-patches] " Георгий Кириченко
2019-02-23 12:30   ` Cyrill Gorcunov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox