cuda.core: GraphBuilder.join leaves forked builders in a state that segfaults at garbage collection if it raises midway
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
Hướng nghiên cứu
Bắt đầu với GraphBuilder.join và các đường dẫn dọn dẹp forked-builder được kiểm thử bởi tests/graph/test_graph_builder.py, sau đó kiểm tra teardown của init_cuda tại dòng 192 trong cuda_core/tests/conftest.py. Sử dụng bản phác thảo tái hiện để khiến Stream.wait phát sinh một exception, chạy hai test graph-builder được nêu tên và xác minh rằng các join thất bại không để lại các capture bị bỏ rơi, đồng thời gc.collect() không còn gây ra segmentation fault.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
If GraphBuilder.join raises partway through, the forked builders it has not yet closed are left open with capturing streams. The test that hit this failed cleanly, but the process then segfaulted during gc.collect() in the init_cuda fixture teardown while those abandoned objects were destroyed. An exception inside join should not be able to crash the interpreter later.
What was observed
On PR #2750, a transient bug made the temporary ordering event in Stream.wait fail to be created. join calls root_bdr.stream.wait(builder.stream) and then builder.close() for each non-root builder; the wait raised on the first builder, so no forked builder was closed. Every GPU test job then crashed with:
Fatal Python error: Segmentation fault
Current thread ... (most recent call first):
File ".../cuda_core/tests/conftest.py", line 192 in init_cuda
Line 192 is the gc.collect() in the fixture's finally. The first tests to fail were test_graph_complete_after_close_forked and test_graph_definition_raises_for_forked in tests/graph/test_graph_builder.py, both of which go through split and join.
https://github.com/NVIDIA/cuda-python/actions/runs/33911046695/job/101149369210
The event-creation bug is fixed in that PR, so the crash is no longer reachable through this route. The teardown fragility remains: any exception in join (or an interrupted split/join sequence) leaves builders in the same state.
Suggested direction
- Make
joinexception-safe: on failure, close or otherwise neutralize the forked builders that were not joined, rather than leaving them mid-capture. - Make the forked-builder destructor tolerant of an abandoned capture, so destruction of a never-joined fork cannot dereference an invalid handle or end capture on a stream that is no longer valid. Identifying the exact dereference is part of this issue; the Python traceback stops at
gc.collect().
Reproduction sketch
gb = Device().create_graph_builder().begin_building()
left, right = gb.split(2)
# force root_bdr.stream.wait(...) to raise inside join, e.g. by monkeypatching Stream.wait
with pytest.raises(Exception):
GraphBuilder.join(left, right)
del left, right, gb
gc.collect() # crashes today
- Ngôn ngữ chính
- Cython
- Star
- 3.4k
- Fork
- 329
- Merge trung bình
- 1 ngày 22 giờ
- Pull request đã merge (30 ngày)
- 117
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 NVIDIA/cuda-python
-
bug cuda.core
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
NVIDIA/cuda-python#2886 · 1 bình luận ·
-
triage
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
NVIDIA/cuda-python#2717 ·
-
triage
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 90/100
NVIDIA/cuda-python#2712 ·
-
[BUG]: LocatedHeaderDir is mutable, so callers can poison the cached header-directory lookup Đang mởtriage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
NVIDIA/cuda-python#2646 · 1 reaction ·
-
cuda.core triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
NVIDIA/cuda-python#2435 · 1 bình luận ·
Tất cả issue của NVIDIA/cuda-python
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
canonical/slurmutils#82 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
-
C++ Enhancement Examples
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100