cURL / Mailing Lists / curl-library / Single Mail

curl-library

thread of application doing ftp upload hangs using libcurl 7.21.0 on windows 2003

From: manish singh <manishsinghhyb_at_gmail.com>
Date: Tue, 19 Oct 2010 11:14:59 +0530

libcurl configuration: Libcurl 7.21.0, built as static lib.
Platform: windows 2003
Compiler: Visual Studio 2008.
Issue occurs on: windows 2003 Virtual Machine

while uploading a file using ftp protocol, the upload thread of
application hangs inside libcurl;

The size of file is 64 MB approximately and at a time, 1MB is being
uploaded.
After some MBs of file data being sent(like 7MB or 8MB), the hang occurs;

Debugging the hang:
==================
On attaching the application to windbg, the following stack trace is
observed:

ChildEBP RetAddr
01eee43c 7c827d29 ntdll!KiFastSystemCallRet
01eee440 71b21af5 ntdll!ZwWaitForSingleObject+0xc
01eee47c 71b21a03 mswsock!SockWaitForSingleObject+0x19d
01eee56c 71c0283c mswsock!WSPSelect+0x380
01eee5bc 004a213c ws2_32!select+0xb9
01eee900 00488c77 dataprotection!Curl_socket_ready(
            unsigned int readfd = <Memory access error>,
            unsigned int writefd = <Memory access error>,
            int timeout_ms = <Memory access error>)+0x13c
[i:\source_code\thirdparty\curl-7.21.0\lib\select.c @ 287]
01eee93c 004894a5 dataprotection!Transfer(
            struct connectdata * conn = <Memory access error>)+0x277
[i:\source_code\thirdparty\curl-7.21.0\lib\transfer.c @ 1355]
01eee95c 00489674 dataprotection!Curl_do_perform(
            struct SessionHandle * data = 0x00000001)+0xa5
[i:\source_code\thirdparty\curl-7.21.0\lib\transfer.c @ 2053]
01eee968 00481970 dataprotection!Curl_perform(
            struct SessionHandle * data = 0x007717b9)+0x14
[i:\source_codethirdparty\curl-7.21.0\lib\transfer.c @ 2177]
01eee974 0076e8e6 dataprotection!curl_easy_perform(
            void * curl = 0x007717b9)+0xa0
[i:\source_code\thirdparty\curl-7.21.0\lib\easy.c @ 567]
01eee9a4 007717b9 dataprotection!tal::SendData(
            void * curl = 0x01be0020,
            struct SendDataInfo * pSendDataInfo = 0x00dd6420,
            bool bAppendMode = true,
            bool bCreateMissingDirectories = true)+0x146
[i:\source_code\host\tal\ftphandlercurl.cpp @ 221]
01eefe8c 0077145b dataprotection!CurlSendWorker::SendInfo(
            void * pCurl = 0x01be0020,
            class ConnectConfigData * pData = 0x00dd5ba8,
            class TransportHandle * pMsg = 0x00dd6578,
            struct SendDataInfo * pSendDataInfo = 0x00dd6420)+0x2c9
[i:\source_code\host\tal\curlsendworker.cpp @ 105]
01eeff04 007719f8 dataprotection!CurlSendWorker::Execute(void)+0x9b
[i:\source_code\host\tal\curlsendworker.cpp @ 58]
01eeff10 00771a82 dataprotection!BaseThread::Run(void)+0x28
[i:\source_code\host\tal\basethread.cpp @ 40]
01eeff1c 0051697b dataprotection!BaseThread::EntryPoint(
            void * pThis = 0x00dba910)+0x12
[i:\source_code\host\tal\basethread.cpp @ 69]
01eeff54 005168e3 dataprotection!ACE_Thread_Adapter::invoke_i(void)+0x6b
[d:\work\sources\trunk\thirdparty\ace-5.6\ace_wrappers\ace\thread_adapter.cpp
@ 146]
01eeff74 006e0ac4 dataprotection!ACE_Thread_Adapter::invoke(void)+0x73
[d:\work\sources\trunk\thirdparty\ace-5.6\ace_wrappers\ace\thread_adapter.cpp
@ 95]
01eeffac 006e0b6c dataprotection!_callthreadstartex(void)+0x1b
[f:\dd\vctools\crt_bld\self_x86\crt\src\threadex.c @ 348]
01eeffb8 77e6482f dataprotection!_threadstartex(
            void * ptd = 0x00dd5c08)+0x82
[f:\dd\vctools\crt_bld\self_x86\crt\src\threadex.c @ 326]
01eeffec 00000000 kernel32!BaseThreadStart+0x34

On printing local variables in windbg, found that the arguments passed
to "select" Winsock API are correct:
1. The write socket fd is set in the "write fd set" and "exception fd set"
2. The timeout of 1 second is passed

From application code, the following options are being set using
"curl_easy_setopt":
1. CURLOPT_NOSIGNAL to 1
2. CURLOPT_CONNECTTIMEOUT to 0
3. CURLOPT_FTP_RESPONSE_TIMEOUT to 300 seconds

Looking at curl code, the hang can be due to two reasons:

1. select windows API itself does not time out even though 1 second is the
   time out:
        This we have tried to simulate with sample winsock test application
   but select never hanged.
2. Due to some code in libcurl, select hangs
   (or)
   select does not hang but it times out properly, and
   the code in function "Transfer" in file "lib/transfer.c"
   calls the "Curl_socket_ready" in an infinite loop

The issue is not getting reproduced consistently but it happened on
the same windows 2003 Virtual Machine four times in a row.

When looking from "netstat -an" command from command line,
the socket used for upload was in "CLOSED_WAIT" state

In need of help on resolving this issue.

Thanks and Regards,
Mannu.

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-10-19