Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Collecting a context together with its memory segfaults

Đã đóng
#714 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 1 ngày

Một pull request liên quan đã được merge.

  • #716 của @maleadt — đã merge

Đá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
25/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
julia
Lĩnh vực
backend

Hướng nghiên cứu

Start with the ZeContext finalizer and the memory allocation and release paths in oneAPI.jl; the issue does not name their files or tests. Trace how context ownership interacts with allocations that become unreachable in the same collection, then check the proposed lifecycle against the CUDA.jl comparison and Level Zero constraints. Done means collecting a context and its allocations no longer segfaults; an open pull request already addresses this issue.

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

Mô tả

runtime

Every Level Zero object is destroyed by its own finalizer, and Julia runs the finalizers of objects that become unreachable in the same collection in no particular order. A ZeContext can thus be destroyed before memory allocated in it, and freeing that memory afterwards crashes in NEO:

using oneAPI, oneAPI.oneL0

function work()
    ctx = ZeContext(oneAPI.driver())
    for _ in 1:3; GC.gc(true); end   # the context is old by the time the array is allocated
    old = context()
    context!(ctx)
    a = oneArray{Float32}(undef, 1_000_000)
    context!(old)
    return
end
work()
GC.gc(true)
[19895] signal 11 (1): Segmentation fault
_ZN2L07Context7freeMemEPKvb at libze_intel_gpu.so.1
zeMemFree at ...

This fails every time on an Iris Xe with NEO 26.35. Without the collections before the allocation the finalizers happen to run in a working order. A context in which a kernel was launched, or small (pooled) arrays were allocated, stays reachable from oneAPI.jl's caches and is never collected, which is probably why this hasn't come up.

Forcing other parent-before-child orders (a queue before its fences, an event pool before its events, a module before its kernels, a command list while it is executing) does not crash on NEO, though the Level Zero spec doesn't allow them either. The context is the one that matters: destroying it frees the allocations made in it.

CUDA.jl avoids this by not destroying contexts from a finalizer at all (CuContext has no finalizer, see also JuliaGPU/CUDA.jl#3404 for releases after an explicit destroy).

Ngôn ngữ chính
Julia
Star
218
Fork
36
Merge trung bình
1 ngày 4 giờ
Pull request đã merge (30 ngày)
57

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

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

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 JuliaGPU/oneAPI.jl

Tất cả issue của JuliaGPU/oneAPI.jl

Issue tương tự

Thêm issue về Julia

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.