From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 4228328027 for ; Sat, 23 Feb 2019 14:49:11 -0500 (EST) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9AevhTDvu8y1 for ; Sat, 23 Feb 2019 14:49:11 -0500 (EST) Received: from smtp38.i.mail.ru (smtp38.i.mail.ru [94.100.177.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 7AAD427733 for ; Sat, 23 Feb 2019 14:49:10 -0500 (EST) From: =?utf-8?B?0JPQtdC+0YDQs9C40Lkg0JrQuNGA0LjRh9C10L3QutC+?= Subject: [tarantool-patches] Re: [PATCH v2] lua/fiber: Fix abort on malformed join input Date: Sat, 23 Feb 2019 22:49:02 +0300 Message-ID: <14237938.h0nRFiLebg@home.lan> In-Reply-To: <20190223133442.GC7198@uranus> References: <20190223133442.GC7198@uranus> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart2323879.aJPgLmKAFl"; micalg="pgp-sha256"; protocol="application/pgp-signature" Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org Cc: Cyrill Gorcunov --nextPart2323879.aJPgLmKAFl Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" 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 > --- > 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") --nextPart2323879.aJPgLmKAFl Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part. Content-Transfer-Encoding: 7Bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEFB+nbqWGnp59Rk9ZFSyY70x8X3sFAlxxo64ACgkQFSyY70x8 X3sI5Qf9EZbZLJaWHk9E23nt7Rl4i2ufhnaBK8spv2G3OVV0vKhZcMf/YctbdyXk HAnncJ2wxJExoiD2oZ6m8rMqDNZORUACVpGcIT58mNbRFA0Xh9SshdNQyhXV8Pm/ DCWClvZsyWxrKc+x5gP6eWMVoDaBBQze2OEW9LmWIyU3Tc93O/UUTu7DAbOzdjQj HT/qQySqxAlFLEkxRLyoACKGhTdMfZVBnuFHASo9JzUUpHLlb05F0uHQryavooeG StHWC3EAviTiaMlGen5TfxRMW5pLbh/BVsBuq38CU4nse0jhPC1EZKMhE3Yq9LEu KFMRU4ZjcYSQX3SXwqZdLeSFXIYcyA== =crQL -----END PGP SIGNATURE----- --nextPart2323879.aJPgLmKAFl--