That's the same problem I experienced,  My first thought --
libcurl + libssh2 cannot be used under 64-bit.
Then I compiled libcurl + libssh2 on Solairs 10 64-bit (x86) and Solaris
8  64-bit (Sun Sparc)
Both work pretty well,  So this problem only happens under Windows x64
 
Unix is based on LP64 model,  Windows 64 is based on LLP64 model.  
 
I guess when the code convert datatype (long to pointer etc. ) ,
something is wrong for LLP64.
 
-Jack

________________________________

From: [email protected]
[mailto:[email protected]] On Behalf Of S.Gopi
Sent: Tuesday, December 28, 2010 17:54
To: [email protected]
Subject: libcurl + libssh2: strange error on Win64 (compiled using VS
2008)



Hi,

  I am trying to use libcurl from my C++ program which will run under
Windows 64 bit.  I could not use MingW since it supports only Windows
32bit.

I compiled libcurl with following support using Visual Studio 2008 in
Windows 2003 R2 X64 Enterprise Edition

libcurl = 7.21.3
OpenSSL = 1.0.0c
zlib = 1.2.5
libssh2 = libssh2-1.2.8-20101221 (daily snapshot)

I got libcurl to work for http and https but I am seeing strange problem
whenever I call libcurl to download files using SCP protocol, they
abruptly exit the whole program (Seg fault).

After messing up with libcurl for few days, I kind of figured out where
exactly this is happening by placing necessary breakpoints and printf
messages. I have attached two screenshots with this message (don't know
whether they are allowed or not).

libcurl-error.jpg was screenshot of my Visual studio during debug
execution, you can see the current state of variables in the bottom
frame of the screenshot.

This is what happens: 
 In scp_recv function in ssh.c,   libssh2_channel_read function is
called which returns ERROR_EAGAIN which is stored in variable 'nread'.
This variable nread is declared ssize_t  (typedef __int64 for Windows 64
in config-win32.h).
For reason which I don't know of, nread has an arbitrary current value
of 4294967259 instead of expected -37 (ERROR_EAGAIN).

This is causing the subsequent if block (if (nread ==
LIBSSH2_ERROR_EAGAIN) to get skipped and returns this arbitrary value
back to caller (Curl_read).  
Curl_read then tries to allocate a buffer of size nread which obviously
causes the segmentation fault and crashes the program. 

Does anyone know a reason for this and how to resolve this ? My second
screenshot should show the output from my printf messages which again
for some unexplained reasons correctly display -37 as the value in nread
(both screenshots taken at same execution time)

BTW, when I declared ssize_t as int  (instead of __int64) in
config_win32.h, then the problem goes away and the file gets downloaded
successfully. 

I have libcurl working successfully in Win32 environment (compiled using
MingW).

I do have latest Platform SDK available for Visual Studio 2008 (Win2k3
R2) installed.

Any pointers on what might be wrong here ? 
Thanks,
Gopi






=============================================================================== 
Please access the attached hyperlink for an important electronic communications 
disclaimer: 
http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html 
=============================================================================== 

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to