fix: propagate error from ncclCudaContextTrack#2249
Open
EylonKrause wants to merge 1 commit into
Open
Conversation
ncclCudaContextTrack captured ncclStrongStreamConstruct's result via NCCLCHECKGOTO but the leave: label hardcoded return ncclSuccess, so a failed stream/event creation was reported as success with a half-initialized context already linked into the global list. Return result so the error propagates. Signed-off-by: EylonKrause <eylon1909@gmail.com>
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.
Description
ncclCudaContextTrack(src/misc/strongstream.cc) captures the result ofncclStrongStreamConstructviaNCCLCHECKGOTO(ncclStrongStreamConstruct(&p->launchOrder), result, leave), but theleave:label hardcodesreturn ncclSuccess. So when stream/event creation fails (e.g. CUDA OOM or an invalid context), the error is swallowed: the caller receivesncclSuccesstogether with a half-initializedncclCudaContext(refCount=1,launchOrdernever constructed) that has already been linked into the global context list, and which is later passed toncclStrongStreamDestruct/...Acquireoperating on a stream that was never created.resultis initialized toncclSuccessand is written only by that singleNCCLCHECKGOTO, so returning it equalsncclSuccesson every path except the genuine failure path — where it now correctly propagates the error.Related Issues
None.
Changes & Impact
src/misc/strongstream.cc:ncclCudaContextTrackreturnsresultinstead of a hardcodedncclSuccess. No change on success paths; on construct failure the error now propagates so the caller fails init instead of proceeding with a corrupt context. Non-breaking.Performance Impact
None — error-path correctness only.
Testing
make src.build(no new warnings).resultisncclSuccesson every success path (initialized so, and only ever written by the oneNCCLCHECKGOTO), so the observable behavior changes only on the failure path, where the previously-swallowed error is now returned.Possible follow-up
This makes the failure observable. A fuller change could also unlink and free the half-built node from the global list on failure, but that involves partial-construct resource cleanup inside
ncclStrongStreamConstruct, so it's left separate to keep this fix minimal and low-risk.