-
Notifications
You must be signed in to change notification settings - Fork 13.5k
std::dynamic_lib: Fix Windows error handling #20874
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
Conversation
r? @huonw (rust_highfive has picked a reviewer for you, use r? to override) |
e2ec01b
to
4fc7861
Compare
// beware: Vec/String may change errno during drop! | ||
// so we get error here. | ||
if result == ptr::null_mut() { | ||
Err(format!("Error code {}", os::errno())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While you're at it, could this get a beefed up error message with the error description as well as the error code?
4fc7861
to
4f5770e
Compare
Now it uses |
216b3eb
to
65d06c4
Compare
This is a [breaking-change] since `std::dynamic_lib::dl` is now private. When `LoadLibraryW()` fails, original code called `errno()` to get error code. However, there was local allocation of `Vec` before `LoadLibraryW()`, and it drops before `errno()`, and the drop (deallocation) changed `errno`! Therefore `dynamic_lib::open()` thought it always succeeded. This commit fixes the issue. This commit also sets Windows error mode during `LoadLibrary()` to prevent "dll load failed" dialog.
65d06c4
to
d053ccb
Compare
Fixed |
⌛ Testing commit d053ccb with merge 658e0bd... |
@bors: retry |
⌛ Testing commit d053ccb with merge 6f161d7... |
💔 Test failed - auto-bsd-64-opt |
@bors: retry |
This is a [breaking-change] since `std::dynamic_lib::dl` is now private. When `LoadLibraryW()` fails, original code called `errno()` to get error code. However, there was local allocation of `Vec` before `LoadLibraryW()`, and it drops before `errno()`, and the drop (deallocation) changed `errno`! Therefore `dynamic_lib::open()` thought it always succeeded. This commit fixes the issue. This commit also sets Windows error mode during `LoadLibrary()` to prevent "dll load failed" dialog.
💔 Test failed - auto-mac-64-nopt-t |
This is a [breaking-change] since `std::dynamic_lib::dl` is now private. When `LoadLibraryW()` fails, original code called `errno()` to get error code. However, there was local allocation of `Vec` before `LoadLibraryW()`, and it drops before `errno()`, and the drop (deallocation) changed `errno`! Therefore `dynamic_lib::open()` thought it always succeeded. This commit fixes the issue. This commit also sets Windows error mode during `LoadLibrary()` to prevent "dll load failed" dialog.
This is a [breaking-change] since
std::dynamic_lib::dl
is nowprivate.
When
LoadLibraryW()
fails, original code callederrno()
to get errorcode. However, there was local allocation of
Vec
beforeLoadLibraryW()
, and it drops beforeerrno()
, and the drop(deallocation) changed
errno
! Thereforedynamic_lib::open()
thoughtit always succeeded.
This commit fixes the issue.
This commit also sets Windows error mode during
LoadLibrary()
toprevent "dll load failed" dialog.