-
Notifications
You must be signed in to change notification settings - Fork 152
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
Fix SCP transfer from hanging indefinitely on Windows. Fixes #107, Fixes 109 #117
Conversation
`libssh2_scp_recv` was deprecated in libssh2. `libssh2_scp_recv2` was introduced with large file support on windows. Calling `libssh2_scp_recv` was returning a stat object with the current timestamp as the remote file size causing the file download to hang indefinitely.
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.
Ah, good find!
The appveyor build failed for this commit; can you try resolving it locally?
These commands should reproduce the failure:
cargo run --manifest-path systest/Cargo.toml --target x86_64-pc-windows-msvc
cargo run --manifest-path systest/Cargo.toml --target i686-pc-windows-msvc
libssh2-sys/lib.rs
Outdated
@@ -494,6 +494,9 @@ extern { | |||
pub fn libssh2_scp_recv(sess: *mut LIBSSH2_SESSION, | |||
path: *const c_char, | |||
sb: *mut libc::stat) -> *mut LIBSSH2_CHANNEL; |
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.
interestingly, libc::stat
appears to be equivalent to _stati64
for the msvc targets, which is in turn what libssh2 chooses in the default windows flavor of the build for its libssh2_struct_stat
type.
Since that is a distinct type from libc::stat
, and there doesn't appear to be a libc::_stat
that we can reference, I feel like it would be a good idea to break libssh2_scp_recv
on windows so that we can't call it now that we know that the type is wrong.
In other words, stick #[cfg(not(windows))]
as an attribute on this to effectively nerf it.
we could just blanket remove |
I'd suggest adding this commit to this PR to resolve my earlier comments:
|
Wouldn't it be better to push the removal of Unless you are planning a major release, wouldn't it be better to just remove it from windows for the time being? |
I believe that the next release will be a major release |
@alexcrichton there's a one-liner to |
This PR will want to define a new function instead of replacing the old function. Additionally the function should be tested via |
@alexcrichton That's my fault; the old function is deprecated on all systems and dangerously broken on windows so I suggested removing it, with the thought that we'd make a breaking version number change in here. regarding systest: it failed in the original version of this PR, but there are no usable diagnostics:
I haven't booted my windows system up yet today, but if memory serves, that issue boiled down to:
|
I think it's fine to keep the deprecated signature around in case anyone is using it, but if systest is failing then that means it's not bound correctly which means that it's just a segfault lurking at runtime to happen at some point in the future. It sounds like |
* Adopt scp_recv2 instead, which uses compatible 64-bit stat types * Mark scp_recv as deprecated * small version bump Fixes alexcrichton#109 Refs alexcrichton#117 Co-authored-by: Joyce Babu <[email protected]>
I think I found a reasonable way to resolve this; I pushed it in this PR: #121 |
* Adopt scp_recv2 instead, which uses compatible 64-bit stat types * Mark scp_recv as deprecated * small version bump Fixes alexcrichton#109 Refs alexcrichton#117 Co-authored-by: Joyce Babu <[email protected]>
Fixed by #121; thanks for this! |
libssh2_scp_recv
was deprecated in libssh2.libssh2_scp_recv2
wasintroduced with large file support on windows. Calling
libssh2_scp_recv
was returning a stat object with the current timestamp as the remote file size
causing the file download to hang indefinitely.