diff --git a/cpp/src/io/utilities/file_io_utilities.cpp b/cpp/src/io/utilities/file_io_utilities.cpp index d96bf93d10f..85a5f7e2281 100644 --- a/cpp/src/io/utilities/file_io_utilities.cpp +++ b/cpp/src/io/utilities/file_io_utilities.cpp @@ -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; @@ -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(dlsym(cf_lib, "cuFileDriverOpen")); CUDF_EXPECTS(driver_open != nullptr, "could not find cuFile cuFileDriverOpen symbol"); driver_close = reinterpret_cast(dlsym(cf_lib, "cuFileDriverClose"));