Skip to content
Snippets Groups Projects
Commit ebcf369a authored by Roman Tsisyk's avatar Roman Tsisyk
Browse files

Fix #420: fiber.cancel() assertion `!(f->flags & (1 << 2))' failed

parent a9c4991d
No related branches found
No related tags found
No related merge requests found
......@@ -133,7 +133,6 @@ void
fiber_cancel(struct fiber *f)
{
assert(f->fid != 0);
assert(!(f->flags & FIBER_CANCEL));
f->flags |= FIBER_CANCEL;
......@@ -180,6 +179,12 @@ fiber_is_cancelled()
void
fiber_testcancel(void)
{
/*
* Fiber can catch FiberCancelException using try..catch block in C or
* pcall()/xpcall() in Lua. However, FIBER_CANCEL flag is still set
* and the subject fiber will be killed by subsequent unprotected call
* of this function.
*/
if (fiber_is_cancelled())
tnt_raise(FiberCancelException);
}
......
No preview for this file type
......@@ -113,3 +113,8 @@ exec admin "lua f = box.fiber.wrap(y)"
exec admin "lua box.fiber.kill(f:id())"
exec admin "lua while box.fiber.status(f) ~= 'dead' do box.fiber.sleep(0.01) end"
exec admin "lua box.space[0]:truncate()"
exec admin "lua done = false"
exec admin "lua function test() box.fiber.name('cancel_bug'); local fun, errmsg = loadstring('box.fiber.cancel(box.fiber.self())'); xpcall(fun, function() end); xpcall(fun, function() end); done = true; fun(); end"
exec admin "lua box.fiber.wrap(test)"
exec admin "lua done"
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