Skip to content

[Coverity] Undefined/unspecified behavior in kernel_bundle_impl::tryGetOfflineKernel #20452

@AlexeySachkov

Description

@AlexeySachkov

See CID 535530. Coverity issues can be accessed via https://scan.coverity.com/projects/intel-llvm?tab=overview

return std::make_shared<kernel_impl>(
std::move(Kernel), *detail::getSyclObjImpl(MContext),
std::move(SelectedImage), *this, ArgMask,
SelectedImage->get_ur_program(), CacheMutex);

The problem here is that evaluation order of function arguments is undefined (pre C++17)/unspecified (post C++17), from cppreference:

Order of evaluation of any part of any expression, including order of evaluation of function arguments is unspecified (with some exceptions listed below). The compiler can evaluate operands and other subexpressions in any order, and may choose another order when the same expression is evaluated again.
14) In a function call, value computations and side effects of the initialization of every parameter are indeterminately sequenced with respect to value computations and side effects of any other parameter. (since C++17)

That means that std::move(SelectedImage) may be evaluated before SelectedImage->get_ur_program() resulting in access to a moved object

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions