[SYCL][UB] Make Command::isHostTask() virtual instead of downcasting on MType - #23081
Merged
KornevNikita merged 1 commit intoSep 2, 2026
Merged
Conversation
…Type isHostTask() static_cast'ed any RUN_CG command to ExecCGCommand and read its command group. The cast relies on an invariant the type tag alone does not express, and ASan flags it as an out-of-bounds read whenever the object is not actually an ExecCGCommand. Ask the command instead of deducing its type. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The virtual dispatch preserves existing host-task behavior while safely handling other command subclasses.
Pull request overview
Replaces unsafe type-tag downcasting with virtual dispatch when identifying host-task commands.
Changes:
- Adds a safe default
Command::isHostTask()implementation. - Overrides host-task detection in
ExecCGCommand. - Removes the undefined-behavior-prone downcast.
File summaries
| File | Description |
|---|---|
sycl/source/detail/scheduler/commands.hpp |
Defines virtual host-task detection. |
sycl/source/detail/scheduler/commands.cpp |
Removes unsafe downcasting logic. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
slawekptak
approved these changes
Sep 2, 2026
Contributor
|
@intel/llvm-gatekeepers please consider merging |
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.
Problem
Command::isHostTask()deduced the dynamic type of the command from its type tag and then downcast unconditionally:static_castto a derived type is undefined behaviour unless the object really is of that type; nothing in the type system enforcesRUN_CG => ExecCGCommand, only convention. When the object is a plainCommandsubobject,getCG()readsMCommandGroupfrom beyond the end of the allocation.AddressSanitizer report (ASan+UBSan build,
SchedulerTest.DontEnqueueDepsIfOneOfThemIsBlocked):Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com