epmd: a client that closes early crashes the server on the PORT_PLEASE2 and NAMES responses

Đang mở Phù hợp với người mới
#2,476 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 3 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
erlang
Lĩnh vực
backend

Hướng nghiên cứu

Đọc libs/avm_network/src/epmd.erl, tập trung vào các nhánh của process_req/3 dành cho ?PORT_PLEASE2_REQ và ?NAMES_REQ, rồi so sánh cách xử lý gửi của chúng với nhánh ALIVE2 được thay đổi bởi #2345. Xác nhận lỗi gửi được xử lý như thế nào và máy chủ vẫn giữ các nút đã đăng ký; công việc hoàn tất khi một trong hai phản hồi có thể gửi thất bại mà không làm epmd gen_server bị lỗi và dừng hoạt động.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Erlang
Star
2.3k
Fork
171
Merge trung bình
4 ngày 11 giờ
Pull request đã merge (30 ngày)
20

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của atomvm/AtomVM

Tất cả issue của atomvm/AtomVM

Issue tương tự

Thêm issue về Backend & API Design

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.