[SYCL] Don't skip memory-record removal when buffer write-back throws - #23082
Open
uditagarwal97 wants to merge 1 commit into
Open
[SYCL] Don't skip memory-record removal when buffer write-back throws#23082uditagarwal97 wants to merge 1 commit into
uditagarwal97 wants to merge 1 commit into
Conversation
If the write-back a buffer performs at destruction fails, the exception escaped updateHostMemory() and the Scheduler::removeMemoryObject() call below it never ran, leaking the memory record and every command it owns, plus the queue and context they reference. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused exception-handling change correctly preserves teardown while retaining asynchronous error reporting.
Pull request overview
Ensures failed SYCL buffer/image write-back does not prevent scheduler and memory cleanup.
Changes:
- Catches copy-back exceptions before teardown.
- Preserves memory-record, host-memory, and interop-resource cleanup.
File summaries
| File | Description |
|---|---|
sycl/source/detail/sycl_mem_obj_t.cpp |
Prevents write-back failures from skipping memory-object cleanup. |
Review details
- Files reviewed: 1/1 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.
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
SYCLMemObjT::updateHostMemory()performs the write-back and then detaches the memory object from the scheduler:MUploadDataFunctor()ends up inScheduler::addCopyBack()followed byEvent->wait(), and a failing copy-back throws fromGraphProcessor::waitForEvent(). The exception then propagates out ofupdateHostMemory(), soremoveMemoryObject(),releaseHostMem()and the interopurMemRelease()below it are all skipped. Both callers (~buffer_impland~image_impl) wrap the call intry { ... } catch (...) {}, so the failure is silently discarded and the object is destroyed with its scheduler record still attached.The leaked set is the whole
MemObjRecord: its alloca/release/copy-back/exec commands, theLeavesCollection, and — becauseCommand::MQueueis ashared_ptr<queue_impl>— the queue and its context with the kernel/program caches. LeakSanitizer reported 41 allocations / ~10.7 KB for a single occurrence (SchedulerTest.FailedCopyBackException), all of them indirect leaks with no direct leak, which is the signature of an orphaned graph rather than a forgottendelete.Fix
Contain the failure so the teardown below always runs:
Observable behavior is unchanged: both existing callers already discarded this exception, and the failure is still reported to the user through the asynchronous exception
Scheduler::addCopyBack()records.Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com