Tarantool development patches archive
 help / color / mirror / Atom feed
* [tarantool-patches] [PATCH v2] lua/fiber: Fix abort on malformed join input
@ 2019-02-23 13:34 Cyrill Gorcunov
  2019-02-23 19:49 ` [tarantool-patches] " Георгий Кириченко
  2019-02-25 12:54 ` [tarantool-patches] " Vladimir Davydov
  0 siblings, 2 replies; 4+ messages in thread
From: Cyrill Gorcunov @ 2019-02-23 13:34 UTC (permalink / raw)
  To: tarantool-patches
  Cc: Георгий
	Кириченко

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")
 

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

* [tarantool-patches] Re: [PATCH v2] lua/fiber: Fix abort on malformed join input
  2019-02-23 13:34 [tarantool-patches] [PATCH v2] lua/fiber: Fix abort on malformed join input Cyrill Gorcunov
@ 2019-02-23 19:49 ` Георгий Кириченко
  2019-02-25 12:54 ` [tarantool-patches] " Vladimir Davydov
  1 sibling, 0 replies; 4+ messages in thread
From: Георгий Кириченко @ 2019-02-23 19:49 UTC (permalink / raw)
  To: tarantool-patches; +Cc: Cyrill Gorcunov

[-- 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 --]

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

* Re: [tarantool-patches] [PATCH v2] lua/fiber: Fix abort on malformed join input
  2019-02-23 13:34 [tarantool-patches] [PATCH v2] lua/fiber: Fix abort on malformed join input Cyrill Gorcunov
  2019-02-23 19:49 ` [tarantool-patches] " Георгий Кириченко
@ 2019-02-25 12:54 ` Vladimir Davydov
  2019-02-25 13:12   ` Cyrill Gorcunov
  1 sibling, 1 reply; 4+ messages in thread
From: Vladimir Davydov @ 2019-02-25 12:54 UTC (permalink / raw)
  To: Cyrill Gorcunov
  Cc: tarantool-patches,
	Георгий
	Кириченко

On Sat, Feb 23, 2019 at 04:34:42PM +0300, 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.

Pushed to 2.1 and 1.10. Thanks!

> 
> v2: by georgy@
>  - add a testcase

We don't include changelog in the commit message. Please put it after
the diff separator (---) so that it is ignored by git-am.

> 
> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>

We don't sign-off patches :-)

> ---
>  src/lua/fiber.c         |    6 +++++-
>  test/app/fiber.result   |   11 +++++++++++
>  test/app/fiber.test.lua |    7 +++++++
>  3 files changed, 23 insertions(+), 1 deletion(-)

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

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

On Mon, Feb 25, 2019 at 03:54:12PM +0300, Vladimir Davydov wrote:
> We don't include changelog in the commit message. Please put it after
> the diff separator (---) so that it is ignored by git-am.

Sure!

> > Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
> 
> We don't sign-off patches :-)

Sure, it is not a problem to not put sob into patches.

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

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-23 13:34 [tarantool-patches] [PATCH v2] lua/fiber: Fix abort on malformed join input Cyrill Gorcunov
2019-02-23 19:49 ` [tarantool-patches] " Георгий Кириченко
2019-02-25 12:54 ` [tarantool-patches] " Vladimir Davydov
2019-02-25 13:12   ` Cyrill Gorcunov

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