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 16B8B28432 for ; Fri, 22 Feb 2019 14:54:04 -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 3XzQT76DYEJa for ; Fri, 22 Feb 2019 14:54:04 -0500 (EST) Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id A3E402842F for ; Fri, 22 Feb 2019 14:54:03 -0500 (EST) Received: by mail-lf1-f68.google.com with SMTP id t14so2618934lfk.7 for ; Fri, 22 Feb 2019 11:54:03 -0800 (PST) Received: from uranus.localdomain ([5.18.103.226]) by smtp.gmail.com with ESMTPSA id g6sm743536lfh.35.2019.02.22.11.54.01 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Feb 2019 11:54:01 -0800 (PST) Date: Fri, 22 Feb 2019 22:53:58 +0300 From: Cyrill Gorcunov Subject: [tarantool-patches] [PATCH] lua,fiber: Fix abort on malformed join input Message-ID: <20190222195358.GZ7198@uranus> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 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 --- 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);