[Tarantool-patches] [PATCH] lua: avoid panic if HOOK_GC is not active

Igor Munkin imun at tarantool.org
Tue Dec 22 19:05:48 MSK 2020


Sergey,

Thanks for the patch! LGTM except a couple of nits below.

Minor: Strictly saying there is no panic if GC hook is not active
(literally any Lua code except the finalizers), but panic occurs when
the active hook is not HOOK_GC. So I propose to tune the commit subject
the following way:
| lua: avoid panic if HOOK_GC is not an active hook

On 22.12.20, Sergey Kaplun wrote:
> Panic at fiber.yield() occures inside any active hook.

Minor: I rearrange this line a bit, feel free to ignore.
| Platform panic occurs when fiber.yield() is used within any active
| (i.e. being executed now) hook.

> 
> This is the regression from 96dbc49d097a96af5273cce2b5663db5917f4ea9
> ('lua: prohibit fiber yield when GC hook is active').
> 
> This patch fixes false positive panic in cases when VM is not running
> a GC hook.
> 
> Reported-by: Michael Filonenko <filonenko.mikhail at gmail.com>
> Follows up #4727

Minor: I guess this patch doesn't follow #4727 but rather #4518
(considering the commit message for the patch you mentioned above). So I
propose to use either "Relates to #4518" or "Follows up #4518" instead.
I personally prefer the first one, since it occured #4518 relates to
totally another issue.

> Closes #5649
> ---
> 
> Branch: https://github.com/tarantool/tarantool/tree/skaplun/gh-5649-fix-for-debug-hook
> Issue: https://github.com/tarantool/tarantool/issues/5649
> CI: https://gitlab.com/tarantool/tarantool/-/pipelines/233249505
> 
>  src/lua/utils.c                               |  2 +-
>  .../gh-5649-yield-in-debug-hook.test.lua      | 25 +++++++++++++++++++
>  2 files changed, 26 insertions(+), 1 deletion(-)
>  create mode 100755 test/app-tap/gh-5649-yield-in-debug-hook.test.lua
> 

<snipped>

> diff --git a/test/app-tap/gh-5649-yield-in-debug-hook.test.lua b/test/app-tap/gh-5649-yield-in-debug-hook.test.lua
> new file mode 100755
> index 000000000..9c1cca51f
> --- /dev/null
> +++ b/test/app-tap/gh-5649-yield-in-debug-hook.test.lua
> @@ -0,0 +1,25 @@
> +#!/usr/bin/env tarantool
> +
> +local fiber = require('fiber')
> +local tap = require('tap')
> +local test = tap.test('yield-in-debug-hook')
> +
> +test:plan(2)
> +
> +-- Test that HOOK_ACTIVE is not enough to panic and
> +-- fiber still can use general hooks at switches.
> +fiber.create(function()
> +  local old_hook, mask, count = debug.gethook()
> +  debug.sethook(function()
> +    fiber.yield()
> +  end, 'c')
> +  -- All ok if panic doesn't occure.
> +  -- Yield before hook is set back.
> +  debug.sethook(old_hook, mask, count)
> +  test:ok(true)
> +end)
> +-- Return to second fiber.

Minor: s/to second/to the second/.

> +fiber.yield()
> +test:ok(true)
> +
> +os.exit(test:check() and 0 or 1)
> -- 
> 2.28.0
> 

-- 
Best regards,
IM


More information about the Tarantool-patches mailing list