curl-library
Re: core dump on curl_easy_cleanup (AIX)
Date: Tue, 2 Nov 2004 10:01:14 -0700
Here is the snippet of the code:
----------------------------------------------------------------------------------------------------------
/*Helper methods*/
struct MemoryStruct {
char *memory;
size_t size;
};
void *myrealloc(void *ptr, size_t size)
{
/* There might be a realloc() out there that doesn't like reallocing
NULL pointers, so we take care of it here */
if(ptr)
return realloc(ptr, size);
else
return malloc(size);
}
size_t WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data)
{
register int realsize = size * nmemb;
struct MemoryStruct *mem = (struct MemoryStruct *)data;
mem->memory = (char *)myrealloc(mem->memory, mem->size + realsize + 1);
if (mem->memory) {
memcpy(&(mem->memory[mem->size]), ptr, realsize);
mem->size += realsize;
mem->memory[mem->size] = 0;
}
return realsize;
}
/*These are the curl calls just a snippet*/
int error=0;
CURL *curl_handle;
struct MemoryStruct chunk;
char *uri;
uri = malloc(1000*sizeof(char));
memset(uri, '\0',1000);
sprintf(uri,"http:///whatever:8080/firstApp/servlet/requestupload?docId=");
strcat(uri,Media_Id);
userlog("URI IS:%s",uri);
pLargeString.pLargeBinString=(void *)malloc(Msc_MaxStringSize+sizeof(long));
pLargeString.len=Msc_MaxStringSize; /* Set Default length */
/* lLen=Msc_MaxStringSize; Set default length */
/********************CURL CALLS*********************/
chunk.memory = NULL; /* we expect realloc(NULL, size) to work */
chunk.size = 0; /* no data at this point */
curl_global_init(CURL_GLOBAL_ALL);
curl_handle = curl_easy_init();
curl_easy_setopt(curl_handle, CURLOPT_HEADER, 0);
/*curl_easy_setopt(curl_handle, CURLOPT_HEADERFUNCTION,writeHeaderBuf );*/
curl_easy_setopt(curl_handle, CURLOPT_URL, uri);
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk);
/*curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0");
curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1);*/
curl_easy_perform(curl_handle);
/*now copy this to our structure*/
memcpy(pLargeString.pLargeBinString, chunk.memory, chunk.size);
pLargeString.len = chunk.size;
free(chunk.memory);
curl_easy_cleanup(curl_handle);
/*******************END OF CURL CALLS*************/
return(&pLargeString);
------------------------------------------------------------------------------------------------------
On Tue, 2 Nov 2004 09:37:17 +0100 (CET), Daniel Stenberg
<daniel-curl_at_haxx.se> wrote:
> On Tue, 2 Nov 2004, Sachin Mahajan wrote:
>
> > Thanks for your example, I will try to do it right:). But I'm still getting
> > the similar core dump pointing to url.c, even after replacing the realloc by
> > myrealloc. Here is the core dbx stack trace:
>
> Tor Arntsen has been building and testing curl automatically on AIX since many
> months (see http://curl.haxx.se/auto/). There is nothing AIX-special in the
> libcurl code in that place that ought to fail.
>
> I consider it very unlikely that you see a libcurl bug, I consider it very
> likely that this is a problem caused by your app.
>
> Can you please post a full example source code (that is as small and simple as
> possible) that makes the problem occur?
>
> --
>
>
> Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se
> Dedicated custom curl help for hire: http://haxx.se/curl.html
>
Received on 2004-11-02