Skip to content

Commit

Permalink
Load libcufile.so with RTLD_NODELETE flag (#9872)
Browse files Browse the repository at this point in the history
Workaround for a known cuFile issue that can lead to segfault if cuFile library is dynamically unloaded.
Using `RTLD_NODELETE` when calling `dlopen` so that the library is not unloaded in `dlclose`.

Also adds a check for the result of dlopen, to help triage cuFile use issues.

Authors:
  - Vukasin Milovanovic (https://github.com/vuule)

Approvers:
  - Christopher Harris (https://github.com/cwharris)
  - Karthikeyan (https://github.com/karthikeyann)

URL: #9872
  • Loading branch information
vuule authored Dec 9, 2021
1 parent 024003c commit 8e5b23c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cpp/src/io/utilities/file_io_utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ class cufile_shim {

~cufile_shim()
{
if (driver_close) driver_close();
if (cf_lib) dlclose(cf_lib);
if (driver_close != nullptr) driver_close();
if (cf_lib != nullptr) dlclose(cf_lib);
}

decltype(cuFileHandleRegister)* handle_register = nullptr;
Expand Down Expand Up @@ -117,7 +117,8 @@ void cufile_shim::modify_cufile_json() const

void cufile_shim::load_cufile_lib()
{
cf_lib = dlopen("libcufile.so", RTLD_NOW);
cf_lib = dlopen("libcufile.so", RTLD_LAZY | RTLD_LOCAL | RTLD_NODELETE);
CUDF_EXPECTS(cf_lib != nullptr, "Failed to load cuFile library");
driver_open = reinterpret_cast<decltype(driver_open)>(dlsym(cf_lib, "cuFileDriverOpen"));
CUDF_EXPECTS(driver_open != nullptr, "could not find cuFile cuFileDriverOpen symbol");
driver_close = reinterpret_cast<decltype(driver_close)>(dlsym(cf_lib, "cuFileDriverClose"));
Expand Down

0 comments on commit 8e5b23c

Please sign in to comment.