Skip to content
Snippets Groups Projects
Commit 404899d8 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Vladimir Davydov
Browse files

lua/fiber: Fix abort on malformed join input

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.
parent 2d1f841e
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
......@@ -1454,6 +1454,14 @@ ch1:put(1)
while f:status() ~= 'dead' do fiber.sleep(0.01) end
---
...
--
-- Test if fiber join() does not crash
-- if unjoinable
--
fiber.join(fiber.self())
---
- error: the fiber is not joinable
...
-- cleanup
test_run:cmd("clear filter")
---
......
......@@ -623,6 +623,12 @@ ch1:put(1)
while f:status() ~= 'dead' do fiber.sleep(0.01) end
--
-- Test if fiber join() does not crash
-- if unjoinable
--
fiber.join(fiber.self())
-- cleanup
test_run:cmd("clear filter")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment