openresty / openresty/lua-nginx-module

coroutine.wrap causes segfault in some cases

Open
#2,058 2 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
11.8k
Forks
2.1k
Avg merge
6h 1m
Merged PRs (30d)
6

Description

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)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the provided Lua reproducer with the resty CLI on the affected lua-nginx-module versions, then inspect the coroutine.wrap implementation introduced by pull request 1239. Done means the reproducer no longer segfaults and the regression is covered by an appropriate test.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, lua
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.