Pranav2612000 commented on code in PR #3844:
URL: https://github.com/apache/arrow-adbc/pull/3844#discussion_r2656840613
##########
rust/driver_manager/src/lib.rs:
##########
@@ -381,6 +381,21 @@ impl ManagedDriver {
let default_entrypoint = get_default_entrypoint(filename.as_ref());
let entrypoint = entrypoint.unwrap_or(default_entrypoint.as_bytes());
+ // By default, go builds the libraries with '-Wl -z nodelete' which
does not
+ // unload the go runtime. This isn't respected on mac (
https://github.com/golang/go/issues/11100#issuecomment-932638093 )
+ // so we need to explicitly load the library with RTLD_NODELETE( which
prevents unloading )
+ #[cfg(unix)]
+ let library: libloading::Library = unsafe {
+ const RTLD_NODELETE: i32 = 0x80;
+
+ libloading::os::unix::Library::open(
+ Some(filename.as_ref()),
+ libloading::os::unix::RTLD_LAZY |
libloading::os::unix::RTLD_LOCAL | RTLD_NODELETE,
+ )
+ .map(Into::into)
+ .map_err(libloading_error_to_adbc_error)?
+ };
+ #[cfg(not(unix))]
let library = unsafe {
libloading::Library::new(filename.as_ref()).map_err(libloading_error_to_adbc_error)?
Review Comment:
I'm not a windows expert, but I see that this flag is not passed when we
load the library. During loading, the
_[LoadLibraryExW](https://learn.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-loadlibraryexw)_
function is called (
[Ref](https://github.com/nagisa/rust_libloading/blob/dab97c569b33bd515e16637b8dedbdc696d9ec9c/src/os/windows/mod.rs#L169)
).
The way to do it in windows is to call the
_[GetModuleHandleExW](https://learn.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getmodulehandleexw)_
function with this flag. `libloading` supports this using the `pin` function (
[Ref](https://github.com/nagisa/rust_libloading/blob/dab97c569b33bd515e16637b8dedbdc696d9ec9c/src/os/windows/mod.rs#L189)
). Let's call this fn in the windows cfg, so that we have the same behaviour
across all platforms?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]