Skip to content

Don't synchronize command lists and queues that were destroyed - #739

Merged
maleadt merged 1 commit into
mainfrom
tb/destroyed-owner-sync
Oct 24, 2026
Merged

maleadt merged 1 commit into
mainfrom
tb/destroyed-owner-sync

Conversation

@maleadt

@maleadt maleadt commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

A task's stream can be collected in the same GC cycle as memory it last used. Julia doesn't order finalizers, so the stream's immediate command list gets destroyed while the freed memory, returned to the pool, still names the stream as its owner. When another task later allocates that memory, it waits for the old owner and synchronizes the destroyed list, which segfaults in the driver. This is the crash in the array tests on Aurora (e.g. pipelines 71586 and 71605, from #734):

signal 11 (1): Segmentation fault
unknown function at /usr/lib64/libze_intel_gpu.so.1
unchecked_zeCommandListHostSynchronize at lib/level-zero/libze.jl:2515
isdone at lib/level-zero/synchronization.jl:25
...
drain at src/memory.jl:92
take_ownership! at src/memory.jl:118

It reproduces on an Arc A770 with the rolling stack too.

The finalizers only destroy a list or queue once its work is done (or the driver waits for it), so this treats a destroyed one as done. It also marks lists and queues destroyed before destroying them rather than after, and does so for queues on every stack, not only on LTS.

A finalizer running on another thread at the same time as the wait can still race with it. Closing that window needs a lock shared by the finalizers and every synchronization, which is left for later.

Fixes #736

A task's stream can be collected in the same GC cycle as memory it last
used. Julia doesn't order finalizers, so the stream's immediate command
list is destroyed while the freed memory, returned to the pool, still
names the stream as its owner. The next allocation of that memory from
another task then waits for the stream, synchronizing the destroyed list,
which segfaults in the driver. This crashed the `array` tests on Aurora.

The finalizers only destroy a list or queue once its work is done, so
treat a destroyed one as done. Mark them destroyed before destroying
them, and do so for queues on every stack, not only on LTS.
@codecov

codecov Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.24%. Comparing base (e00acd7) to head (e9c73e2).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #739      +/-   ##
==========================================
- Coverage   85.71%   85.24%   -0.48%     
==========================================
  Files          55       54       -1     
  Lines        4955     4831     -124     
==========================================
- Hits         4247     4118     -129     
- Misses        708      713       +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@maleadt
maleadt merged commit c1dea4f into main Oct 24, 2026
5 checks passed
@maleadt
maleadt deleted the tb/destroyed-owner-sync branch October 24, 2026 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Segfault in zeCommandListHostSynchronize when reusing memory last used by a finished task

1 participant