[UR][L0] Fix event refcount bugs in L0 v1 adapter barrier handling#21871
Open
winstonzhang-intel wants to merge 1 commit intointel:syclfrom
Open
[UR][L0] Fix event refcount bugs in L0 v1 adapter barrier handling#21871winstonzhang-intel wants to merge 1 commit intointel:syclfrom
winstonzhang-intel wants to merge 1 commit intointel:syclfrom
Conversation
Fixes three issues in the Level Zero v1 adapter that caused urEventWait to be called for an internal event crashes and segfaults when mixing multiple in-order queues with ext_oneapi_submit_barrier. 1. Fix insertBarrierIntoCmdList passing InterruptBasedEventsEnabled as IsMultiDevice to createEventAndAssociateQueue. Barrier events do not need multi-device visibility; pass false instead. 2. In urEventWait, replace die() with continue when hasExternalRefs() is false. A recycled event (RefCountExternal == 0) was already completed before recycling, so skipping the wait is safe. 3. In urEventRelease, use CleanupCompletedEvent (which is a no-op when CleanedUp is true) instead of calling urEventReleaseInternal directly. The old code double-released the internal refcount when CleanupEventListFromResetCmdList had already cleaned the event. UR_L0_SERIALIZE=2 masked the race by forcing synchronous execution. UR_L0_DISABLE_EVENTS_CACHING=1 turned the recycling into a delete, escalating the bug from a stale-data read to a segfault. Fixes: intel#21704 Signed-off-by: Zhang, Winston <winston.zhang@intel.com>
413e058 to
5ea16f3
Compare
kswiecicki
reviewed
Apr 30, 2026
| ur_event_handle_t_ *Event = ur_cast<ur_event_handle_t_ *>(e); | ||
| if (!Event->hasExternalRefs()) | ||
| die("urEventWait must not be called for an internal event"); | ||
| continue; |
Contributor
There was a problem hiding this comment.
Is urEventWait must not be called for an internal event no longer valid?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes three issues in the Level Zero v1 adapter that caused urEventWait to be called for an internal event crashes and segfaults when mixing multiple in-order queues with ext_oneapi_submit_barrier.
Fix insertBarrierIntoCmdList passing InterruptBasedEventsEnabled as IsMultiDevice to createEventAndAssociateQueue. Barrier events do not need multi-device visibility; pass false instead.
In urEventWait, replace die() with continue when hasExternalRefs() is false. A recycled event (RefCountExternal == 0) was already completed before recycling, so skipping the wait is safe.
In urEventRelease, use CleanupCompletedEvent (which is a no-op when CleanedUp is true) instead of calling urEventReleaseInternal directly. The old code double-released the internal refcount when CleanupEventListFromResetCmdList had already cleaned the event.
UR_L0_SERIALIZE=2 masked the race by forcing synchronous execution. UR_L0_DISABLE_EVENTS_CACHING=1 turned the recycling into a delete, escalating the bug from a stale-data read to a segfault.
Fixes: #21704