Skip to content

Commit 7a144a9

Browse files
bwlodarczsys-ce-bb
authored andcommitted
Access out of scope fix in OCLToSPIRVBase::visitCallReadWriteImage (#2265)
ImageOpMask pointer was passed to closure as reference. Closure is executed outside of original stack frame which renders reference invalid. Fixes some ASan errors from issue #2233. Original commit: KhronosGroup/SPIRV-LLVM-Translator@29d4cd3
1 parent a567b25 commit 7a144a9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

llvm-spirv/lib/SPIRV/OCLToSPIRV.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,8 +1079,9 @@ void OCLToSPIRVBase::visitCallReadWriteImage(CallInst *CI,
10791079
Info.UniqName = kOCLBuiltinName::ReadImage;
10801080
unsigned ImgOpMask = getImageSignZeroExt(DemangledName);
10811081
if (ImgOpMask) {
1082-
Info.PostProc = [&](BuiltinCallMutator &Mutator) {
1083-
Mutator.appendArg(getInt32(M, ImgOpMask));
1082+
Module *Mod = M;
1083+
Info.PostProc = [ImgOpMask, Mod](BuiltinCallMutator &Mutator) {
1084+
Mutator.appendArg(getInt32(Mod, ImgOpMask));
10841085
};
10851086
}
10861087
}

0 commit comments

Comments
 (0)