cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-tracker mailing list Archives

[ curl-Bugs-1561470 ] Crash in curl_multi_cleanup on upload to ftp errors

From: SourceForge.net <noreply_at_sourceforge.net>
Date: Wed, 20 Sep 2006 04:16:04 -0700

Bugs item #1561470, was opened at 2006-09-19 15:22
Message generated for change (Comment added) made by bagder
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=1561470&group_id=976

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: ftp
Group: crash
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Daniel Stenberg (bagder)
Summary: Crash in curl_multi_cleanup on upload to ftp errors

Initial Comment:
danil at mtsnet.ru

Platform: Win2000, mingw-2.95.2
libcurl: libcurl-7.15.4 and libcurl-7.15.6-20060911
+ssl builds downloaded from the official site

This is the similar bug to the described in https://
sourceforge.net/tracker/index.php?func=detail&aid=
1560773&group_id=976&atid=100976 but it happens during
cleanup of the multi handle after unsuccesful ftp
upload:

In the example below I'm running guildFTPd localy:

* About to connect() to 127.0.0.1 port 21
* Expire at 888825 / 165000 (300000ms)
* Trying 127.0.0.1... * connected
* Connected to 127.0.0.1 (127.0.0.1) port 21
* Expire cleared
* Remembering we are in dir Upload/test
< 220-GuildFTPd FTP Server (c) 1997-2002
< 220-Version 0.999.13
< 220 Please enter your name:
* server did not report OK, got 220
* Connection #0 to host 127.0.0.1 left intact
^^^^^
1) First we see that libcurl misinterprets ftpd result
of the ftpd (I don't see it in the easy-mode nor in
the application i've hit originally this bug).
2) When trying to release multi handle after this (or
other errors) - libcurl crashes

#include <stdio.h>
#include <curl/curl.h>

const char* theData = "this is a test\n";
int hasNotBeenSent = 1;

int fRead(void *dataPtr, unsigned items, unsigned
size, void* whatever);

int main()
{
        CURLSH *curlShare;
        CURLM* multiHandle;
        CURL* easyHandle;
        CURLcode curlCode;
        int isMultiRunning;

        curl_global_init(CURL_GLOBAL_ALL );

        easyHandle = curl_easy_init();
        curl_easy_setopt( easyHandle, CURLOPT_VERBOSE,
1);
        curl_easy_setopt( easyHandle, CURLOPT_
READFUNCTION, fRead);
        curl_easy_setopt( easyHandle, CURLOPT_READDATA,
0);
        curl_easy_setopt( easyHandle, CURLOPT_URL, "ftp:/
/127.0.0.1/Upload/test");
        curl_easy_setopt( easyHandle, CURLOPT_
INFILESIZE, strlen(theData) );
        curl_easy_setopt( easyHandle, CURLOPT_UPLOAD, 1);

        multiHandle = curl_multi_init();
        curl_multi_add_handle( multiHandle, easyHandle
 );

        while(curlCode = curl_multi_perform(
multiHandle, &isMultiRunning ),
                                                curlCode == CURLM_
CALL_MULTI_PERFORM) ;;;

        curl_multi_remove_handle(multiHandle,
easyHandle);
        
        curl_multi_cleanup(multiHandle);
        printf("I can not get here\n");
        curl_easy_cleanup(easyHandle);
        curl_global_cleanup();

        return 0;
}

int fRead(void *dataPtr, unsigned items, unsigned
size, void* whatever)
{
        /* send the string one time */
        return hasNotBeenSent ?
                memcpy( dataPtr, theData, strlen(theData
)), hasNotBeenSent = 0, strlen (theData)
                : 0 ;
}

----------------------------------------------------------------------

>Comment By: Daniel Stenberg (bagder)
Date: 2006-09-20 13:16

Message:
Logged In: YES
user_id=1110

I agree this shouldn't crash. Can you provide any details on
the actual crash, like file and line number and possibly the
contents of some local variables at the time of the crash?

Your example code is however not something that is likely to
ever succeed in an upload since you seem to have forgot to
read the man page for curl_multi_perform() and especially
its return codes.

And as a side-note your "unorthodox" (ab)use of the comma
operator makes your program hard to follow.

Test case 525 makes an FTP upload fine using the multi
interface.

----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2006-09-20 07:49

Message:
Logged In: NO

danil at mtsnet.ru

The trace looks strange for me too - but this is exactly
what i see when I run the code in the example. Another
strange thing is that the example code doesn't do an
upload, but the similar code from program I'm writing
currently (it is a libcurl binding for squeak smalltalk ) -
does (a can not instantly provide trace from it, because I
need to rebuild squeak vm as the console application or to
make hooks to the debug functions).

So, the first upload from squeak goes ok, the second upload
is not permitted by server because file is already there -
crash when releasing the multi handle.
I didn't manage to exactly reproduce this behaviour in C -
it fails from the start, but the example reflects my main
concern anyway - crash in multi_handle_cleanup when ftp
upload failed.

If you need any additional info or things to try - please
ask

----------------------------------------------------------------------

Comment By: Daniel Stenberg (bagder)
Date: 2006-09-19 21:20

Message:
Logged In: YES
user_id=1110

That trace isn't complete, is it?

It says "Remembering we are in..." very early, which is what
it normally says after an FTP transfer.

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=1561470&group_id=976
Received on 2006-09-20

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET