curl-library
RE: FW: segfault in curl_formfree() in persistence run onRHEL5x86-64as64 bit app
Date: Fri, 18 Dec 2009 17:45:57 +0530
Even getting segfault with CURL 7.12.0. This only happens on RHEL5
x86-64. Not on Win2k8 64 bit. Not with any of the 32 bit code. This is
only happening after long run of the code. We are using OpenSSL 0.9.8.k
as 64 bit. Both CURL and Openssl linked as static libs. Can it be
confirmed that following code can run with out any memory corruption for
long duration on 64 bit OS? Let me know if you want further info. I
think you may ignore SSL part. If I remove res =
curl_easy_perform(curl); then I don't see crash that easily.
Sending sample code.
char* file_name = NULL; //use some file
char* content_type = "text/plain";
char msg[] = "message";
struct curl_httppost *post = NULL;
struct curl_httppost *last = NULL;
CURL *curl = NULL;
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK)
{
goto err_exit;
}
/* add stats file to http post */
curl_formadd(&post, &last,
CURLFORM_COPYNAME,msg,
CURLFORM_FILECONTENT, file_name,
CURLFORM_CONTENTTYPE, (char*)content_type,
CURLFORM_END);
/* initialize a rda curl session */
if((curl = curl_easy_init()) == NULL)
{
goto err_exit;
}
/* set a useragent header */
if(curl_easy_setopt( curl, CURLOPT_USERAGENT, native_agent_header)
!= CURLE_OK)
{
goto err_exit;
}
/* set a timeout for curl */
curl_easy_setopt( curl, CURLOPT_TIMEOUT, config->http_timeout);
/* Verify ssl host name */
res = curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2);
if(res != CURLE_OK)
{
goto err_exit;
}
/* set trusted cert file */
res = curl_easy_setopt(curl, CURLOPT_CAINFO, ca_cert);
if(res != CURLE_OK)
{
goto err_exit;
}
/* Verify ssl certificate */
res = curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1);
if(res != CURLE_OK)
{
goto err_exit;
}
/* Set the form info */
curl_easy_setopt(curl, CURLOPT_HTTPPOST, post);
memset(err_string,'\0',CURL_ERROR_SIZE);
/* Set URL */
res = curl_easy_setopt(curl, CURLOPT_URL, url);
if(res != CURLE_OK)
{
goto err_exit;
}
/* Set file to write to */
if( file != NULL )
{
if(res != CURLE_OK)
{
bmi_log( BMI_LOG_ERR, BMI_CURL_SETOPT_FAILED_s_d, "file",
res);
goto err_exit;
}
}
/* Set previous date of file */
res = curl_easy_setopt(curl,CURLOPT_TIMEVALUE, 0);
if(res != CURLE_OK)
{
goto err_exit;
}
/* Set error string buffer */
res = curl_easy_setopt(curl,CURLOPT_ERRORBUFFER,(char*)err_string);
if(res != CURLE_OK)
{
goto err_exit;
}
/* Perform action */
res = curl_easy_perform(curl);
if(res != CURLE_OK)
{
goto err_exit;
}
/* Get result of action */
res = curl_easy_getinfo(curl,CURLINFO_HTTP_CODE,http_code);
if(res != CURLE_OK)
{
goto err_exit;
}
err_exit:
if(post != NULL)
{
curl_formfree( post );
}
if(file != NULL)
{
fclose(file);
}
if( curl != NULL)
{
curl_easy_cleanup(curl);
}
curl_global_cleanup();
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2009-12-18