cURL / Mailing Lists / curl-library / Single Mail

curl-library

curl_easy_perform results in segmentation fault

From: Marcus Mundt <Marcus.Mundt_at_forsa.de>
Date: Fri, 23 Apr 2010 16:14:57 +0200

Hi guys,

hopefully anyone can point me to the place where I made a mistake. I'm new
to libcurl and not very experienced in c programming. This is the source
involved:

global init takes place in the main() which is run before resume().

void resume () {
        curl = curl_easy_init();
        if(curl) {
                strcat(data, "server_ip=192.168.101.10&session_name=");
                if (session && agent_log_id) {
                        printf("SESSION = ");
                        printf(session);
                        printf("\nagent_log_id = ");
                        printf(agent_log_id);
                        printf("\n");
                        strcat(data, session);
                        strcat(data, "&ACTION=VDADready&user=");
                        strcat(data, user);
                        strcat(data, "&pass=");
                        strcat(data, pass);
                        strcat(data, "&stage=READY&agent_log_id=");
                        strcat(data, agent_log_id);
                        strcat(data, "&agent_log=undefined&wrapup=undefined&campaign=111");
                        printf("TEST12\n");
                        /* what URL receives this POST */
                        curl_easy_setopt(curl, CURLOPT_URL,
"http://192.168.101.10/agc/vdc_db_query.php");
                        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
                        //curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, temp2);
                        printf("TEST13\n");
                        printf("TEST14\n");
                        //curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemory);
                        printf("TEST15\n");
                        /* we pass our 'chunk' struct to the callback function */
                        //curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&chunk);
                        printf("TEST16\n");
                        // SEGMENTATION FAULT!!!!!!!!!!!!!11
                        /* post away! */
                        res = curl_easy_perform(curl);
                        if(res != CURLE_OK) {
                                //curl_easy_cleanup(curl);
                                printf("Error: ");
                                printf(curl_easy_strerror(res));
                                printf("\n");
                }
                        //printf("CURLOPT_ERRORBUFFER - temp2 = ");
                        //printf(temp2);
                        printf("\nTEST17\n");
                }
                /* session, id etc. aus vars/params oder kommandozeile holen */
                else {

                }
                // one time the program crashed here
                // Interviewer resume OK, but double free or corruption (out): 0x0805d7c8
                // curl_easy_cleanup+0x21
                printf("\nTEST18\n");
                printf("\n");
                printf("curl_easy_cleanup(curl);");
                curl_easy_cleanup(curl);
                printf("\nTEST19 - nach easy cleanup in resume()\n");
                printf("\n");
        }

}

The whole source can be found here:
http://pastebin.com/WDXhrzD1

Any help is highly appreciated. Thanks a lot in advance.

Cheers,
Marcus

---------------------------------
forsa
Gesellschaft für Sozialforschung
und statistische Analysen mbH
Max-Beer-Straße 2/4
10119 Berlin
Telefon: (0 30) 6 28 82-0
Telefax: (0 30) 6 28 82-4 00
e-mail: info_at_forsa.de

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