epmd: a client that closes early crashes the server on the PORT_PLEASE2 and NAMES responses
Maintainers usually reply within 3 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- erlang
- Domain
- backend
Research direction
Read libs/avm_network/src/epmd.erl, focusing on process_req/3 branches for ?PORT_PLEASE2_REQ and ?NAMES_REQ, and compare their send handling with the ALIVE2 branch changed by #2345. Confirm how send failures are handled and that the server keeps its registered nodes; done means either response can fail to send without crashing the epmd gen_server.
Written by the indexing model from the issue text.
Description
Affected: release-0.7 at ca1583068, libs/avm_network/src/epmd.erl,
process_req/3 for ?PORT_PLEASE2_REQ and ?NAMES_REQ.
#2345 fixes the same problem for the ALIVE2 response only.
What happens
The responses are sent with ok = socket:send(Socket, ...).
When the client has already closed the connection, socket:send/2 does not
return ok (on release-0.7 it returns {ok, Data} for a closed connection,
with #2345 it returns {error, closed} or {error, epipe}). The badmatch
crashes the epmd gen_server, and every registered node is forgotten.
How to reproduce
Start the epmd, then from any client:
{ok, S} = socket:open(inet, stream, tcp),
ok = socket:setopt(S, {socket, linger}, #{onoff => true, linger => 0}),
ok = socket:connect(S, #{family => inet, addr => loopback, port => 4369}),
ok = socket:send(S, <<2:16, 122, "x">>), % PORT_PLEASE2_REQ for node "x"
ok = socket:close(S). % reset, no reply is read
The server's reply fails and the epmd process crashes. The race is easiest to
hit with a slow server, for example under valgrind.
Suggested fix
Handle {error, _} like the ALIVE2 branch does after #2345: close the socket
and keep the state.
- Dominant language
- Erlang
- Stars
- 2.3k
- Forks
- 171
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 20
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
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.
More from atomvm/AtomVM
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 3 days
-
lwIP sockets: a failed listen or connect leaves the socket lock held, a later close hangs foreverOpen
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 3 days
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
G-nn-r/lg_heatpump#52 ·
-
area: core bug priority: high
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
griffinwork40/agent-afk#4872 ·
Maintainers usually reply within 1 day
-
fleet size/m
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
sipyourdrink-ltd/bernstein#7517 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
storytold/photocraft#14025 ·
Maintainers usually reply within 1 day