Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

https request causes segmentation fault

by eisdrache (Novice)
on Oct 30, 2006 at 01:51 UTC ( #581169=perlquestion: print w/replies, xml ) Need Help??

eisdrache has asked for the wisdom of the Perl Monks concerning the following question:

I have a script which takes a given url, examines the header of the page and then prints the server info to stdout. Very simple code, here it is for reference:

use strict; use LWP::Simple; print "URL: "; chomp(my $url = <STDIN>); my (undef, undef, undef, undef, $server) = head($url); print "Server: $server\n";

If I enter any url using standard http protocol (e.g. the script works fine. However, if I enter a url using https protocol (e.g. the script fails with a segmentation fault (coredump).

My LWP module supports https, I have OpenSSL installed, and I have Crypt::SSLeay and Net::SSLeay installed. But I cannot get past this problem and I am ready to start pulling my hair out over it.

Any ideas are much appreciated. Thank you in advance for any help.

Replies are listed 'Best First'.
Re: https request causes segmentation fault
by Zaxo (Archbishop) on Oct 30, 2006 at 02:41 UTC

    That's not enough information to say what's going wrong.

    If your system has strace or ktrace, try running your script under that. It will show pretty clearly where and why the segfault happens.

    After Compline,

      I am running this on a Solaris box, so I used truss. I know this most likely not a perl issue anymore, but just incase anyone has any insight, here is the last few lines of the truss output:
      3055: Incurred fault #6, FLTBOUNDS %pc = 0xFED0E03C 3055: siginfo: SIGSEGV SEGV_MAPERR addr=0x000000A4 3055: Received signal #11, SIGSEGV [default] 3055: siginfo: SIGSEGV SEGV_MAPERR addr=0x000000A4
      I wish I could give more info but I am baffled at this problem, I have never experienced anything like it before. Anyway, thanks for your reply. I am unfamiliar with strace and ktrace, how exactly would I go about using one of those?

        The strace or ktrace utils are found on unix-like systems. The simplest usage is, e.g.,

        prompt> strace perl
        which will be followed by a huge dump of information.

        If you're on a winders system, perhaps someone who knows will suggest an equivalent diagnostic utility.

        After Compline,

        Assuming that you are on a linux system, either do a man strace or check out the man page for strace. IIRC, ktrace is more of a *BSD thing. If you are using a BSD platform, then check out the ktrace man page. It all depends on what platform you are doing this all on.
        These tools can print out information about system calls that the perl interpreter makes to your operating system to get things done. (eg: opening a file and any error that occurred) I don't normally use strace until I'm out of other ideas but it can be helpful.

        On Linux you can use strace, on Solaris truss, and on OpenBSD ktrace. Check out the man page or try googling for some examples.
Re: https request causes segmentation fault
by madbombX (Hermit) on Oct 30, 2006 at 02:46 UTC
    You are also not checking the return value of head() here. It may provide you with more information if you provided a catch in here of some sort (die, warn, carp, etc).

    (my (undef, undef, undef, undef, $server) = head($url)) or die "Document Header Error: $!";

    You may also want to try running the script within the perl debugger and see if you are provided with any more useful information.

Re: https request causes segmentation fault
by perrin (Chancellor) on Oct 30, 2006 at 19:08 UTC
    This often means that you are running this code with some XS libraries (Crypt::SSLeay) that were compiled with a different version of perl than the one you are running, or with a different compiler.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://581169]
Approved by GrandFather
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2022-05-27 02:07 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (94 votes). Check out past polls.