openresty / openresty/lua-nginx-module

sock:receive() timeout on unix socket results in SIGSEGV

Open
#2,126 0 comments 0 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

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

  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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.