Skip to content

Resource leaks in online compiler implementation #16330

Closed
@AlexeySachkov

Description

@AlexeySachkov

void *OclocLibrary = sycl::detail::ur::loadOsLibrary(OclocLibraryName);
if (!OclocLibrary)
throw online_compile_error("Cannot load ocloc library: " +
OclocLibraryName);

loadOsLibrary is a wrapper around dlopen/LoadLibraryEx and both those functions require a de-allocation call once resource has been used. However, we don't do that at all in our online compiler implementation.

Note that resource leak will happen every time we throw an exception. It is not like this is a high-impact thing, because if we threw an exception saying that we couldn't load ocloc, it is unlikely that we will succeed on retry and most likely such exception will cause a SYCL app to reach a full stop. At this point, OS should help us properly free all resources.

However, that is still an issue which static analyzer highlights, regardless of its actual impact. The suggestion here is that we update our loadOsLibrary function to return a unique_ptr which will have a correct deleter assigned to it. That way, resources will be freed automatically.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions