openresty / openresty/lua-nginx-module
sock:receive() timeout on unix socket results in SIGSEGV
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 11.8k
- Forks
- 2.1k
- Avg merge
- 6h 1m
- Merged PRs (30d)
- 6
Description
I noticed that such code in my content_by_lua block
local sock = ngx.socket.udp()
sock:setpeername('unix:/run/validator')
sock:send({ some, data, here })
sock:settimeout(2000) -- milis
local okay = sock:receive()
if socket not listening, produces this in error.log
2022/11/19 12:11:18 [crit] 79811#79811: *1 connect() failed (111: Connection refused), client: ::1, server: ...
2022/11/19 12:11:18 [error] 79811#79811: *1 send() failed (107: Transport endpoint is not connected), client: ::1, server: ...
2022/11/19 12:11:20 [alert] 79809#79809: worker process 79811 exited on signal 11 (core dumped)
First two messages are expected. The last is not. Why timeout expiry crashes worker with SIGSEGV?? Do I miss anything?
Server: openresty/1.21.4.1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the Lua code using sock:receive() after the Unix socket connection is refused, then inspect the resulting worker core dump and the socket receive path. Done means the timeout or failed socket is handled without a SIGSEGV while the expected connection errors remain visible.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, lua, nginx
- Domain
- backend, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100