cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Crash in curl

From: Andreas Volz <lists_at_brachttal.net>
Date: Sun, 17 Feb 2008 20:11:35 +0100

Am Sat, 16 Feb 2008 00:35:51 +0100 (CET) schrieb Daniel Stenberg:

> On Sat, 16 Feb 2008, Andreas Volz wrote:
>
> > I get a crash sometimes when calling curl_easy_perform() from my
> > application. Not sure why it happens. Maybe it's a memory overwrite
> > from my application, because my download function works everytime
> > from my unit tests. But it fails in the real application. See here
> > the backtrace:
>
> [...]
>
> > #0 Curl_http_done (conn=0x83670b8, status=CURLE_OK,
> > premature=false) at http.c:1615
>
> What is going on at that particular line where the crash occurs?

CURLcode Curl_http_done(struct connectdata *conn,
                        CURLcode status, bool premature)
{
  struct SessionHandle *data = conn->data;
  struct HTTP *http =data->reqdata.proto.http;
  struct Curl_transfer_keeper *k = &data->reqdata.keep;
  (void)premature; /* not used */

  /* set the proper values (possibly modified on POST) */
  conn->fread = data->set.fread; /* restore */
  conn->fread_in = data->set.in; /* restore */

  if (http == NULL)
    return CURLE_OK;

  if(http->send_buffer) {
    send_buffer *buff = http->send_buffer; // (1)

--> free(buff->buffer);
    free(buff);
    http->send_buffer = NULL; /* clear the pointer */
  }
...

gdb tells me that the value of 'buff' is 0x1. For sure this is the
reason why my application is crashing. The other values in 'conn' are
looking good.

> >> curl-config --version
> > libcurl 7.16.4
>
> [...]
>
> > The really interesting thing is that my application works on a
> > second Linux system with curl-7.17.1 installed. So maybe it's a
> > curl problem?
>
> I don't understand. Is the problem on 7.16.4 or on 7.17.1?

The problem is with 7.16.4

> What if you try 7.18.0, does that show the problem as well?

It's not so easy to replace a system component like curl on Ubuntu if
not included in the distribution.

> Seeing you run on Linux, have you tried running your app with
> valgrind?

Yes, but no error is reported while using valgrind. I simply see a
segfault and nothing else. No error summary from valgrind. It looks
as if valgrind dies too. I tested my valgrind installation with various
other tools and it works. I don't understand it.

regards
Andreas
Received on 2008-02-17