AsyncSRT.dispose()/worker.terminate() causes native heap corruption (reproduces on v1.5.5 and v1.5.6)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- javascript, node.js
- Lĩnh vực
- backend, networking
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện kịch bản close-then-dispose trong spec/async_srt_await_spec.js và đọc triển khai AsyncSRT trong src/async.js. So sánh các async spec hiện có, sau đó làm cho việc dispose chờ native socket teardown trước khi worker shutdown và thêm coverage cho close plus dispose; hoàn tất khi các spec vượt qua mà không có lỗi heap-corruption hoặc lỗi teardown.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
AsyncSRT.dispose() (which calls Worker.terminate() under the hood — see src/async.js) causes native heap corruption when called on a worker that has active or recently-closed SRT sockets. This reproduces on both v1.5.5 and v1.5.6 of the bundled libSRT — it is unrelated to the version-bump work in #89/#90.
This code path currently has no test coverage: dispose()/worker.terminate() is never called in spec/async_srt_await_spec.js (it's commented out) and is absent from every other spec file.
Reproduction
In a spec exercising AsyncSRT: create socket(s), close them via the async API, then call dispose() on the AsyncSRT instance (which calls Worker.terminate()) before the process exits.
Observed on Linux (node:20-bookworm, arm64, matching CI's toolchain):
free(): invalid pointer
and, on other runs of the same scenario:
free(): invalid next size (fast)
and one occurrence of a V8 fatal error during worker teardown:
Check failed: node->IsInUse().
All are consistent with a race between Worker.terminate() tearing down the worker thread/its Realm and the native addon's own in-flight close()/socket-teardown state still running inside that same worker thread — i.e. terminate() doesn't wait for the native binding's cleanup to finish before the thread (and its heap) is torn down.
Why this matters
Heap corruption (free(): invalid pointer / invalid next size) is a use-after-free/double-free class bug — exploitable in principle, not just a crash. Any application using AsyncSRT.dispose() for graceful shutdown (a reasonable, expected use of a public API method) can hit this today, independent of which libSRT version is bundled.
Suggested fix direction
Worker.terminate() is inherently abrupt — it doesn't let in-flight work finish. A safer dispose() likely needs to:
- signal the worker to finish any pending native
close()/socket teardown and acknowledge completion (e.g. a message round-trip) before callingworker.terminate(), or - avoid
terminate()entirely in favor of a graceful shutdown message the worker acts on and then exits on its own.
Suggested test coverage
Un-comment and fix the existing dispose() call in spec/async_srt_await_spec.js, and add explicit close+dispose coverage to the other async spec files, so this path is exercised by CI going forward.
Found incidentally while investigating #89/#90 (libSRT v1.5.6 CVE fix); filed separately since it's unrelated to that work and affects the current release.
- Ngôn ngữ chính
- JavaScript
- Star
- 99
- Fork
- 35
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Eyevinn/node-srt
-
bug ready-for-maintainer
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Security: bundled libSRT v1.5.5 is vulnerable to CVE-2026-55869 and CVE-2026-55868 (fixed upstream in v1.5.6)Có thể đã có người làm @birme đã nhận 87 ngày trước. Đang mởbuild-issue ready-for-maintainer
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Accept() closes the listener socket on success — a listener can only accept one connectionCó thể đã có người làm @cdgraff đã nhận 117 ngày trước. Đang mởbug ready-for-maintainer
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 66/100
-
question ready-for-maintainer
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
Tất cả issue của Eyevinn/node-srt
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Fei2411/DeepSeek-Bot#1194 ·
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
andromarces/agent-loops#1735 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Link Checker ReportĐang mởautomated issue report
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Undo after deleting a todoĐang mởenhancement good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
BinaryBaconLabs/todo-app#32 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Missing assertions to legacy Cafe Menu block testsCó thể đã có người làm @mariamanbar đã nhận hôm nay. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
freeCodeCamp/freeCodeCamp#71624 ·
Maintainer thường phản hồi trong vòng 1 ngày