lua-nginx-module icon indicating copy to clipboard operation
lua-nginx-module copied to clipboard

coroutine.wrap causes segfault in some cases

Open fffonion opened this issue 3 years ago • 2 comments

The following code when ran with resty CLI will cause segfault, it seems to be caused by the coroutine.wrap API introduced by https://github.com/openresty/lua-nginx-module/pull/1239.

I've tested on lua-nginx-module shipped with 1.21.4.1 and 1.19.9.2, but it may also trigger on older versions.

local fn = function(r)
  coroutine.wrap(
    function()
      error("aaaaaa")
    end
  )()
end

local co = coroutine.create(fn)
coroutine.resume(co)

debug.traceback(co)

fffonion avatar Jun 15 '22 04:06 fffonion

If it isn't already, this would make for a valuable unit test.

curiositycasualty avatar Jun 15 '22 17:06 curiositycasualty

Remove debug.traceback(co) and it works.

cppcoffee avatar Jun 17 '22 06:06 cppcoffee