Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

detail::image_mem_impl destructor may throw an exception even though it is implicitly nothrow #16331

Open
AlexeySachkov opened this issue Dec 11, 2024 · 0 comments
Labels
bug Something isn't working confirmed sycl-bindless-images SYCL Bindless Images

Comments

@AlexeySachkov
Copy link
Contributor

The following destructor may throw sycl::exception, but being implicitly nothrow this will result in std::terminate which could be unexpected for our users:

detail::image_mem_impl::~image_mem_impl() {
free_image_mem(this->get_handle(), this->get_descriptor().type,
this->get_device(), this->get_context());
}

Exception could be thrown here:

__SYCL_EXPORT void free_image_mem(image_mem_handle memHandle,
image_type imageType,
const sycl::device &syclDevice,
const sycl::context &syclContext) {
std::shared_ptr<sycl::detail::context_impl> CtxImpl =
sycl::detail::getSyclObjImpl(syclContext);
ur_context_handle_t C = CtxImpl->getHandleRef();
std::shared_ptr<sycl::detail::device_impl> DevImpl =
sycl::detail::getSyclObjImpl(syclDevice);
ur_device_handle_t Device = DevImpl->getHandleRef();
const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter();
if (memHandle.raw_handle != 0) {
if (imageType == image_type::mipmap) {
Adapter->call<sycl::errc::memory_allocation,
sycl::detail::UrApiKind::urBindlessImagesMipmapFreeExp>(
C, Device, memHandle.raw_handle);
} else if (imageType == image_type::standard ||
imageType == image_type::array ||
imageType == image_type::cubemap) {
Adapter->call<sycl::errc::memory_allocation,
sycl::detail::UrApiKind::urBindlessImagesImageFreeExp>(
C, Device, memHandle.raw_handle);
} else {
throw sycl::exception(sycl::make_error_code(sycl::errc::invalid),
"Invalid image type to free");
}
}
}

Either from Plugin->call, or just by falling to that else branch at the end which does direct throw

@AlexeySachkov AlexeySachkov added bug Something isn't working confirmed sycl-bindless-images SYCL Bindless Images labels Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working confirmed sycl-bindless-images SYCL Bindless Images
Projects
None yet
Development

No branches or pull requests

1 participant