cURL / Mailing Lists / curl-users / Single Mail

curl-users

Segmentation fault (core dumped)

From: Michael S. Steuer <michael_at_steuer.com>
Date: Fri, 7 Sep 2001 00:45:32 +0200

Hi All,

I have a problem with libcurl in combination with Perl. When I execute
the code below, I get a dumped core. It happens when I 'perform'. What
am I doing wrong?? Why does it dump?

Thanks in advance, regards, Michael.

--------------- THE CODE -------------------

use Curl::easy;

# Do the DB Stuff here

# Init the curl session
my $curl;
$curl = Curl::easy::init();

print "ok\n";

#
# Set some options here before doing it...

# No progress meter
#Curl::easy::setopt($curl, CURLOPT_NOPROGRESS, 1);

# Shut up completely
#Curl::easy::setopt($curl, CURLOPT_MUTE, 1);

# Follow location headers
Curl::easy::setopt($curl, CURLOPT_FOLLOWLOCATION, 1);

# Set timeout
Curl::easy::setopt($curl, CURLOPT_TIMEOUT, 30);

# Add some additional headers to the http-request:
my @myheaders;
$myheaders[0] = "Server: www";
$myheaders[1] = "User-Agent: Perl interface for libcURL";
Curl::easy::setopt($curl, Curl::easy::CURLOPT_HTTPHEADER, \@myheaders);
                                                                        
# Store error messages in variable $errbuf
# NOTE: The name of the variable is passed as a string!
# setopt() creates a perl variable with that name, and
# perform() stores the errormessage into it if an error occurs.

$url = "http://www.nu.nl/";

Curl::easy::setopt($curl, CURLOPT_ERRORBUFFER, "errbuf");
Curl::easy::setopt($curl, CURLOPT_URL, $url);

print "ok2\n";

my $bytes;
my $realurl;
my $httpcode;
my $errbuf;

#
# Go do it
if (Curl::easy::perform($curl) == 0) {
    Curl::easy::getinfo($curl, CURLINFO_SIZE_DOWNLOAD, $bytes);
    print "ok 6: $bytes bytes read\n";
    Curl::easy::getinfo($curl, CURLINFO_EFFECTIVE_URL, $realurl);
    Curl::easy::getinfo($curl, CURLINFO_HTTP_CODE, $httpcode);
    print "effective fetched url (http code: $httpcode) was: $url\n";
} else {
   # We can acces the error message in $errbuf here
    print "$errbuf\n";
    #log the ERRBUF
}

# Cleanup
Curl::easy::cleanup($curl);
Received on 2001-09-07