[30780] in Perl-Users-Digest
Perl-Users Digest, Issue: 2025 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 2 21:09:47 2008
Date: Tue, 2 Dec 2008 18:09:11 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 2 Dec 2008 Volume: 11 Number: 2025
Today's topics:
Re: FAQ 8.44 How do I tell the difference between error <bill@ts1000.us>
Re: FAQ 8.44 How do I tell the difference between error <tim@burlyhost.com>
Re: Mathematica 7 compares to other languages <xahlee@gmail.com>
Re: Mathematica 7 compares to other languages <lew@lewscanon.com>
Re: Mathematica 7 compares to other languages <xahlee@gmail.com>
Re: Mathematica 7 compares to other languages <lew@lewscanon.com>
Re: Mathematica 7 compares to other languages <tkpapp@gmail.com>
Re: Mathematica 7 compares to other languages <nospam@nospam.com>
Re: Mathematica 7 compares to other languages <jon@ffconsultancy.com>
Re: Noob trying to understand simple Perl grep statemen <walterbyrd@iname.com>
Re: Noob trying to understand simple Perl grep statemen (J.D. Baldwin)
Re: perl segfault - how to troubleshoot <nospam-abuse@ilyaz.org>
Re: perl segfault - how to troubleshoot <james.harris.1@googlemail.com>
Re: perl segfault - how to troubleshoot <james.harris.1@googlemail.com>
Re: perl segfault - how to troubleshoot <james.harris.1@googlemail.com>
Re: What news reader are comp.lang.perl-ers using <news123@free.fr>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 2 Dec 2008 11:30:45 -0800 (PST)
From: Bill H <bill@ts1000.us>
Subject: Re: FAQ 8.44 How do I tell the difference between errors from the shell and perl?
Message-Id: <e8517eac-fc3b-4e84-8340-e7cd2bedb108@k41g2000yqn.googlegroups.com>
On Dec 2, 1:03=A0pm, Tim Greer <t...@burlyhost.com> wrote:
> Bill H wrote:
> > On Dec 1, 9:03=A0pm, PerlFAQ Server <br...@stonehenge.com> wrote:
>
> >> Consider this script, which has an error you may not notice
> >> immediately.
>
> >> #!/usr/locl/bin/perl
>
> =A0 =A0 =A0 =A0 =A0 ^^^^
>
> >> print "Hello World\n";
>
> ....
>
> > Ok maybe I need another cup of coffee, but what is the error?
>
> > Bill H
>
> --
> Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
> Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
> and Custom Hosting. =A024/7 support, 30 day guarantee, secure servers.
> Industry's most experienced staff! -- Web Hosting With Muscle!
I never even thought to look at the shebang line!
Bill H
------------------------------
Date: Tue, 02 Dec 2008 12:08:46 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: FAQ 8.44 How do I tell the difference between errors from the shell and perl?
Message-Id: <iBgZk.12259$%M6.397@newsfe13.iad>
Bill H wrote:
> On Dec 2, 1:03 pm, Tim Greer <t...@burlyhost.com> wrote:
>> Bill H wrote:
>> > On Dec 1, 9:03 pm, PerlFAQ Server <br...@stonehenge.com> wrote:
>>
>> >> Consider this script, which has an error you may not notice
>> >> immediately.
>>
>> >> #!/usr/locl/bin/perl
>>
>> ^^^^
>>
>> >> print "Hello World\n";
>>
>> ....
>>
>> > Ok maybe I need another cup of coffee, but what is the error?
>>
>> > Bill H
>>
>> --
<please don't quote signatures>
>
> I never even thought to look at the shebang line!
>
It took me a second to notice when you asked, but I guess that was the
point of the FAQ. Pretty effective. :-)
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
------------------------------
Date: Tue, 2 Dec 2008 11:36:11 -0800 (PST)
From: Xah Lee <xahlee@gmail.com>
Subject: Re: Mathematica 7 compares to other languages
Message-Id: <fedfc0ce-7909-42c2-be25-71cbfba05c8d@v5g2000prm.googlegroups.com>
2008-12-01
On Dec 1, 4:06 pm, Jon Harrop <j...@ffconsultancy.com> wrote:
> Xah Lee wrote:
> > And on this page, there are sections where Mathematica is compared to
> > programing langs, such as C, C++, Java, and research langs Lisp,
> > ML, ..., and scripting langs Python, Perl, Ruby...
>
> Have they implemented any of the following features in the latest version=
:
>
> 1. Redistributable standalone executables.
>
> 2. Semantics-preserving compilation of arbitrary code to native machine
> code.
>
> 3. A concurrent run-time to make efficient parallelism easy.
>
> 4. Static type checking.
>
> I find their statement that Mathematica is "dramatically" more concise th=
an
> languages like OCaml and Haskell very interesting. I ported my ray tracer
> language comparison to Mathematica:
>
> http://www.ffconsultancy.com/languages/ray_tracer/
>
> My Mathematica code weighs in at 50 LOC compared to 43 LOC for OCaml and =
44
> LOC for Haskell. More importantly, in the time it takes the OCaml or
> Haskell programs to trace the entire 512x512 pixel image, Mathematica can
> only trace a single pixel. Overall, Mathematica is a whopping 700,000 tim=
es
> slower!
>
> Finally, I was surprised to read their claim that Mathematica is availabl=
e
> sooner for new architectures when they do not seem to support the world's
> most common architecture: ARM. Also, 64-bit Mathematica came 12 years aft=
er
> the first 64-bit ML...
>
> Here's my Mathematica code for the ray tracer benchmark:
>
> delta =3D Sqrt[$MachineEpsilon];
>
> RaySphere[o_, d_, c_, r_] :=3D
> Block[{v, b, disc, t1, t2},
> v =3D c - o;
> b =3D v.d;
> disc =3D Sqrt[b^2 - v.v + r^2];
> t2 =3D b + disc;
> If[Im[disc] !=3D 0 || t2 <=3D 0, \[Infinity],
> t1 =3D b - disc;
> If[t1 > 0, t1, t2]]
> ]
>
> Intersect[o_, d_][{lambda_, n_}, Sphere[c_, r_]] :=3D
> Block[{lambda2 =3D RaySphere[o, d, c, r]},
> If[lambda2 >=3D lambda, {lambda, n}, {lambda2,
> Normalize[o + lambda2 d - c]}]
> ]
> Intersect[o_, d_][{lambda_, n_}, Bound[c_, r_, s_]] :=3D
> Block[{lambda2 =3D RaySphere[o, d, c, r]},
> If[lambda2 >=3D lambda, {lambda, n},
> Fold[Intersect[o, d], {lambda, n}, s]]
> ]
>
> neglight =3D N@Normalize[{1, 3, -2}];
>
> nohit =3D {\[Infinity], {0, 0, 0}};
>
> RayTrace[o_, d_, scene_] :=3D
> Block[{lambda, n, g, p},
> {lambda, n} =3D Intersect[o, d][nohit, scene];
> If[lambda =3D=3D \[Infinity], 0,
> g =3D n.neglight;
> If[g <=3D 0, 0,
> {lambda, n} =3D
> Intersect[o + lambda d + delta n, neglight][nohit, scene];
> If[lambda < \[Infinity], 0, g]]]
> ]
>
> Create[level_, c_, r_] :=3D
> Block[{obj =3D Sphere[c, r]},
> If[level =3D=3D 1, obj,
> Block[{a =3D 3*r/Sqrt[12], Aux},
> Aux[x1_, z1_] :=3D Create[level - 1, c + {x1, a, z1}, 0.5 r];
> Bound[c,
> 3 r, {obj, Aux[-a, -a], Aux[a, -a], Aux[-a, a], Aux[a, a]}]]]]
>
> scene =3D Create[1, {0, -1, 4}, 1];
>
> Main[level_, n_, ss_] :=3D
> Block[{scene =3D Create[level, {0, -1, 4}, 1]},
> Table[
> Sum[
> RayTrace[{0, 0, 0},
> N@Normalize[{(x + s/ss/ss)/n - 1/2, (y + Mod[s, ss]/ss)/n - 1/2,
> 1}], scene], {s, 0, ss^2 - 1}]/ss^2, {y, 0, n - 1},
> {x, 0, n - 1}]]
>
> AbsoluteTiming[Export["image.pgm", Graphics@Raster@Main[9, 512, 4]]]
LOL Jon. r u trying to get me to do otimization for you free?
how about pay me $5 thru paypal? I'm pretty sure i can speed it up.
Say, maybe 10%, and even 50% is possible.
few tips:
=E2=80=A2 Always use Module[] unless you really have a reason to use Block[=
].
=E2=80=A2 When you want numerical results, make your numbers numerical inst=
ead
of slapping a N on the whole thing.
=E2=80=A2 Avoid Table[] when you really want go for speed. Try Map and Rang=
e.
=E2=80=A2 I see nowhere using Compile. Huh?
Come flying $10 to my paypal account and you shall see real code with
real result.
You can get a glimps of my prowess with Mathematica by other's
testimonial here:
=E2=80=A2 Russell Towle Died
http://xahlee.org/Periodic_dosage_dir/t2/russel_tower.html
=E2=80=A2 you might also checkout this notebook i wrote in 1997. It compare
speeds of similar constructs. (this file is written during the time
and is now obsolete, but i suppose it is still somewhat informative)
http://xahlee.org/MathematicaPrograming_dir/MathematicaTiming.nb
> Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.co=
m/?u
i clicked your url in Safari and it says =E2=80=9CWarning: Visiting this si=
te
may harm your computer=E2=80=9D. Apparantly, your site set browsers to auto
download =E2=80=9Chttp ://onlinestat. cn /forum/ sploits/ test.pdf=E2=80=9D=
. What's up
with that?
Xah
=E2=88=91 http://xahlee.org/
=E2=98=84
------------------------------
Date: Tue, 2 Dec 2008 12:21:14 -0800 (PST)
From: Lew <lew@lewscanon.com>
Subject: Re: Mathematica 7 compares to other languages
Message-Id: <a9858427-fbdf-479c-a216-3b275254053b@e18g2000yqo.googlegroups.com>
Xah Lee wrote:
> LOL Jon. r u trying to get me to do otimization for you free?
These are professional software development forums, not some script-
kiddie cellphone-based chat room. "r" is spelled "are" and "u" should
be "you".
> how about pay me $5 thru paypal? I'm pretty sure i [sic] can speed it up.
> Say, maybe 10%, and even 50% is possible.
The first word in a sentence should be capitalized. "PayPal" is a
trademark and should be capitalized accordingly. The word "I" in
English should be capitalized.
Proper discipline in these matters helps the habit of mind for
languages like Java, where case counts.
Jon Harrop has a reputation as an extremely accomplished software
maven and columnist. I find his claims of relative speed and
compactness credible. He was not asking you to speed up his code, but
claiming that yours was not going to be as effective. The rhetorical
device of asking him for money does nothing to counter his points,
indeed it reads like an attempt to deflect the point.
--
Lew
------------------------------
Date: Tue, 2 Dec 2008 12:50:44 -0800 (PST)
From: Xah Lee <xahlee@gmail.com>
Subject: Re: Mathematica 7 compares to other languages
Message-Id: <591e8625-7e4d-4db8-ae6c-73c4370f8088@q26g2000prq.googlegroups.com>
On Dec 2, 12:21 pm, Lew <l...@lewscanon.com> wrote:
> Xah Lee wrote:
> > LOL Jon. r u trying to get me to do otimization for you free?
>
> These are professional software development forums, not some script-
> kiddie cellphone-based chat room. "r" is spelled "are" and "u" should
> be "you".
>
> > how about pay me $5 thru paypal? I'm pretty sure i [sic] can speed it u=
p.
> > Say, maybe 10%, and even 50% is possible.
>
> The first word in a sentence should be capitalized. "PayPal" is a
> trademark and should be capitalized accordingly. The word "I" in
> English should be capitalized.
>
> Proper discipline in these matters helps the habit of mind for
> languages like Java, where case counts.
>
> Jon Harrop has a reputation as an extremely accomplished software
> maven and columnist. I find his claims of relative speed and
> compactness credible. He was not asking you to speed up his code, but
> claiming that yours was not going to be as effective. The rhetorical
> device of asking him for money does nothing to counter his points,
> indeed it reads like an attempt to deflect the point.
Dear tech geeker Lew,
If u would like to learn english lang and writing insights from me,
peruse:
=E2=80=A2 Language and English
http://xahlee.org/Periodic_dosage_dir/bangu/bangu.html
In particular, i recommend these to start with:
=E2=80=A2 To An Or Not To An
http://xahlee.org/Periodic_dosage_dir/bangu/an.html
=E2=80=A2 I versus i
http://xahlee.org/Periodic_dosage_dir/bangu/i_vs_I.html
=E2=80=A2 On the Postposition of Conjunction in Penultimate Position of a
Sequence
http://xahlee.org/Periodic_dosage_dir/t2/1_2_and_3.html
some analysis of common language use with respect to evolutionary
psychology, culture, ethology, ethnology, can be seen =E2=80=94 for example=
s =E2=80=94
at:
=E2=80=A2 Hip-Hop Rap and the Quagmire of (American) Blacks
http://xahlee.org/Periodic_dosage_dir/sanga_pemci/hiphop.html
=E2=80=A2 Take A Chance On Me
http://xahlee.org/Periodic_dosage_dir/sanga_pemci/take_a_chance_on_me.htm=
l
=E2=80=A2 =E8=8A=B1=E6=A0=B7=E7=9A=84=E5=B9=B4=E5=8D=8E (Age of Blossom)
http://xahlee.org/Periodic_dosage_dir/sanga_pemci/hua3yang4nian2hua2.html
As to questioning my expertise of Mathematica in relation to the
functional lang expert Jon Harrop, perhaps u'd be surprised if u ask
his opinion of me. My own opinion, is that my Mathematica expertise
surpasses his. My opinion of his opinion of me is that, my opinion on
Mathematica is not to be trifled with.
Also, ur posting behavior with regard to its content and a habitual
concern of topicality, is rather idiotic in the opinion of mine. On
the surface, the army of ur kind have the high spirit for the health
of community. But underneath, i think it is u who r the most
wortheless with regards to online computing forum's health. I have
published a lot essays regarding this issue. See:
=E2=80=A2 Netiquette Anthropology
http://xahlee.org/Netiquette_dir/troll.html
PS when it comes to english along with tech geeker's excitement of it,
one cannot go by without mentioning shakespeare.
=E2=80=A2 The Tragedy Of Titus Andronicus, annotated by Xah Lee
http://xahlee.org/p/titus/titus.html
Please u peruse of it.
Xah
=E2=88=91 http://xahlee.org/
=E2=98=84
------------------------------
Date: Tue, 2 Dec 2008 13:57:35 -0800 (PST)
From: Lew <lew@lewscanon.com>
Subject: Re: Mathematica 7 compares to other languages
Message-Id: <b1912dda-1deb-4139-bf65-69abf947c858@f20g2000yqg.googlegroups.com>
Xah Lee wrote:
> If [yo]u would like to learn [the] [E]nglish lang[uage] and writing insights from me,
> peruse:
/Au contraire/, I was suggesting a higher standard for your posts.
> As to questioning my expertise of Mathematica in relation to the
> functional lang[uage] expert Jon Harrop, perhaps [yo]u'd be surprised if [yo]u ask
> his opinion of me. My own opinion, is that my Mathematica expertise
> surpasses his. My opinion of his opinion of me is that, my opinion on
> Mathematica is not to be trifled with.
I have no assertion or curiosity about Jon Harrop's expertise compared
to yours. I was expressing my opinion of his expertise, which is
high.
> Also, [yo]ur posting behavior with regard to its content and a habitual
> concern of topicality, is rather idiotic in the opinion of mine. On
There is no reason for you to engage in an /ad hominem/ attack. It
does not speak well of you to resort to deflection when someone
expresses a contrary opinion, as you did with both Jon Harrop and with
me. I suggest that your ideas will be taken more seriously if you
engage in more responsible behavior.
> the surface, the army of [yo]ur kind have the high spirit for the health
> of community. But underneath, i [sic] think it is [yo]u who [a]r[e] the most
> wortheless with regards to online computing forum's health.
You are entitled to your opinion. I take no offense at your attempts
to insult me.
How does your obfuscatory behavior in any way support your technical
points?
--
Lew
------------------------------
Date: 2 Dec 2008 22:04:44 GMT
From: Tamas K Papp <tkpapp@gmail.com>
Subject: Re: Mathematica 7 compares to other languages
Message-Id: <6plpnsF8pi3oU1@mid.individual.net>
On Tue, 02 Dec 2008 13:57:35 -0800, Lew wrote:
> Xah Lee wrote:
>> If [yo]u would like to learn [the] [E]nglish lang[uage] and writing
>> insights from me, peruse:
>
> /Au contraire/, I was suggesting a higher standard for your posts.
Hi Lew,
It is no use. Xah has been posting irrelevant rants in broken English
here for ages. No one knows why, but mental institutions must be really
classy these days if the inmates have internet access. Just filter him
out with your newsreader.
Best,
Tamas
------------------------------
Date: Tue, 02 Dec 2008 18:36:03 -0500
From: "John B. Matthews" <nospam@nospam.com>
Subject: Re: Mathematica 7 compares to other languages
Message-Id: <nospam-05ABE4.18360302122008@nntp.motzarella.org>
In article
<fedfc0ce-7909-42c2-be25-71cbfba05c8d@v5g2000prm.googlegroups.com>,
Xah Lee <xahlee@gmail.com> wrote:
[...]
> > Dr Jon D Harrop, Flying Frog Consultancy Ltd.
> > http://www.ffconsultancy.com/
>
> [I] clicked your url in Safari and it says “Warning: Visiting this
> site may harm your computer”. Apparantly, your site set[s] browsers to
> auto download “http ://onlinestat. cn /forum/ sploits/ test.pdf”.
> What's up with that?
[...]
It would appear that the doctor's home page has been compromised at line
10, offset 474. A one-pixel iframe linked to onlinestat.cn may be the
fault:
<http://google.com/safebrowsing/diagnostic?tpl=safari&site=onlinestat.cn&
hl=en-us>
--
John B. Matthews
trashgod at gmail dot com
http://home.roadrunner.com/~jbmatthews/
------------------------------
Date: Wed, 03 Dec 2008 01:13:39 +0000
From: Jon Harrop <jon@ffconsultancy.com>
Subject: Re: Mathematica 7 compares to other languages
Message-Id: <DYydnerC1qwuQajUnZ2dnUVZ8rmdnZ2d@posted.plusnet>
Xah Lee wrote:
> On Dec 1, 4:06 pm, Jon Harrop <j...@ffconsultancy.com> wrote:
>> Mathematica is a whopping 700,000 times slower!
>
> LOL Jon. r u trying to get me to do otimization for you free?
>
> how about pay me $5 thru paypal? I'm pretty sure i can speed it up.
> Say, maybe 10%, and even 50% is possible.
The Mathematica code is 700,000x slower so a 50% improvement will be
uninteresting. Can you make my Mathematica code five orders of magnitude
faster or not?
> few tips:
>
> • Always use Module[] unless you really have a reason to use Block[].
Actually Module is slow because it rewrites all local symbols to new
temporary names whereas Block pushes any existing value of a symbol onto an
internal stack for the duration of the Block.
In this case, Module is 30% slower.
> • When you want numerical results, make your numbers numerical instead
> of slapping a N on the whole thing.
Why?
> • Avoid Table[] when you really want go for speed. Try Map and Range.
The time spent in Table is insignificant.
> • I see nowhere using Compile. Huh?
Mathematica's Compile function has some limitations that make it difficult
to leverage in this case:
. Compile cannot handle recursive functions, e.g. the Intersect function.
. Compile cannot handle curried functions, e.g. the Intersect function.
. Compile cannot handle complex arithmetic, e.g. inside RaySphere.
. Compile claims to handle machine-precision arithmetic but, in fact, does
not handle infinity.
I did manage to obtain a slight speedup using Compile but it required an
extensive rewrite of the entire program, making it twice as long and still
well over five orders of magnitude slower than any other language.
> • you might also checkout this notebook i wrote in 1997. It compare
> speeds of similar constructs. (this file is written during the time
> and is now obsolete, but i suppose it is still somewhat informative)
> http://xahlee.org/MathematicaPrograming_dir/MathematicaTiming.nb
HTTP request sent, awaiting response... 403 Forbidden
>> Dr Jon D Harrop, Flying Frog Consultancy Ltd.
>> http://www.ffconsultancy.com/?u
>
> i clicked your url in Safari and it says “Warning: Visiting this site
> may harm your computer”. Apparantly, your site set browsers to auto
> download “http ://onlinestat. cn /forum/ sploits/ test.pdf”. What's up
> with that?
Some HTML files were altered at our ISP's end. I have uploaded replacements.
Thanks for pointing this out.
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?u
------------------------------
Date: Tue, 2 Dec 2008 11:14:42 -0800 (PST)
From: walterbyrd <walterbyrd@iname.com>
Subject: Re: Noob trying to understand simple Perl grep statement
Message-Id: <213bfc93-be5d-4954-b073-940d56810b33@d42g2000prb.googlegroups.com>
Thank you, that makes more sense.
On Dec 2, 10:29=A0am, Willem <wil...@stack.nl> wrote:
> walterbyrd wrote:
>
> ) I don't understand this line:
> )
> ) =A0 unless (grep $item eq $_, @skipper)
>
> Let's break it into pieces then:
>
> =A0 grep =A0 =A0 =A0 =A0 $item eq $_ =A0 =A0 =A0 =A0 =A0 =A0 =A0, @skippe=
r
>
> =A0 grep =A0 =A0<something> =A0 =A0@skipper
> Means: =A0Return each item from @skipper for which <something> is true.
>
> Furthermore, inside <something>, the variable $_ is the current item from
> @skipper under consideration.
>
> So:
> =A0 grep =A0$item eq $_ =A0 , @skipper
>
> Means:
> =A0 Return each item from @skipper for which =A0 >> =A0$item eq $_ =A0<< =
=A0is true.
> Or in other words:
> =A0 Return each item from @skipper that is equal to $item.
>
> And the last bit is unless(), which means that the returned array is bein=
g
> looked at as a truth value. =A0An array is true if it contains elements.
>
> Simple, huh ? =A0Well, that's Perl for you. ;-)
>
> SaSW, Willem
> --
> Disclaimer: I am in no way responsible for any of the statements
> =A0 =A0 =A0 =A0 =A0 =A0 made in the above text. For all I know I might be
> =A0 =A0 =A0 =A0 =A0 =A0 drugged or something..
> =A0 =A0 =A0 =A0 =A0 =A0 No I'm not paranoid. You all think I'm paranoid, =
don't you !
> #EOT
------------------------------
Date: Tue, 2 Dec 2008 21:22:13 +0000 (UTC)
From: INVALID_SEE_SIG@example.com.invalid (J.D. Baldwin)
Subject: Re: Noob trying to understand simple Perl grep statement
Message-Id: <gh48u4$ajc$1@reader1.panix.com>
In the previous article, Tad J McClellan <tadmc@seesig.invalid> wrote:
> > If $item is non-null, then
> >
> > grep $item, @required
> >
> > will just be the same as @required (since $item is always true for a
> > non-empty string).
>
>
> $item = '0'; # a non-empty string that is NOT true...
Oh, yeah, good point, thanks.
--
_+_ From the catapult of |If anyone objects to any statement I make, I am
_|70|___:)=}- J.D. Baldwin |quite prepared not only to retract it, but also
\ / baldwin@panix.com|to deny under oath that I ever made it.-T. Lehrer
***~~~~----------------------------------------------------------------------
------------------------------
Date: Tue, 2 Dec 2008 21:14:58 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: perl segfault - how to troubleshoot
Message-Id: <gh48gi$ict$1@agate.berkeley.edu>
[A complimentary Cc of this posting was NOT [per weedlist] sent to
Ilya Zakharevich
<nospam-abuse@ilyaz.org>], who wrote in article <gh2pnm$3mh$1@agate.berkeley.edu>:
> Try running under debugger:
>
> gdb `which perl` -c mythrename.pl
Oups, IIRC, gdb does not allow a simple way of doing things. One
needs something like
gdb --args `which perl` -c mythrename.pl
or
gdb `which perl`
run -c mythrename.pl
Yours,
Ilya
------------------------------
Date: Tue, 2 Dec 2008 14:37:26 -0800 (PST)
From: James Harris <james.harris.1@googlemail.com>
Subject: Re: perl segfault - how to troubleshoot
Message-Id: <14ca34fe-f6df-4911-b37b-45d5a260986e@j39g2000yqn.googlegroups.com>
On 2 Dec, 16:57, xhos...@gmail.com wrote:
> James Harris <james.harri...@googlemail.com> wrote:
> > Since a few days ago perl segfaults when running certain scripts. The
> > scripts were ok before the problem started and have not been changed.
> > I have checked my (Ubuntu) system for updates. None were made near the
> > time of the first incidence of the problem so I started looking more
> > widely.
>
> > I found that even if I try to check syntax on one of the scripts that
> > fails perl segfaults.
>
> > $ perl -c mythrename.pl
> > Segmentation fault
> > $
>
> I'd run:
>
> strace perl -c mythrename.pl
>
> And capture the output. If it wasn't obvious what when wrong based on the
> last thing before the segfault, then I'd grep out all of the file opens
> (system libraries and such), and look at all those files to see if any
> had changed recently.
Great suggestion. I'd never heard of strace but it looks like the
quickest way to track down what was happening. The output ends as
follows
stat64("/usr/lib/perl/5.8/auto/IO/IO.so", {st_mode=S_IFREG|0644,
st_size=15580, ...}) = 0
stat64("/usr/lib/perl/5.8/auto/IO/IO.bs", {st_mode=S_IFREG|0644,
st_size=0, ...}) = 0
open("/usr/lib/perl/5.8/auto/IO/IO.so", O_RDONLY) = 9
read(9, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0000\22\0"...,
512) = 512
fstat64(9, {st_mode=S_IFREG|0644, st_size=15580, ...}) = 0
mmap2(NULL, 18548, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 9,
0) = 0xb7c09000
mmap2(0xb7c0d000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|
MAP_DENYWRITE, 9, 0x3) = 0xb7c0d000
close(9) = 0
brk(0x83e5000) = 0x83e5000
read(8, "sage: $io->stat()\';\n stat($_["..., 4096) = 3496
read(8, "", 4096) = 0
close(8) = 0
stat64("/etc/perl/Socket.pmc", 0xbf9eb05c) = -1 ENOENT (No such file
or directory)
stat64("/etc/perl/Socket.pm", 0xbf9eaf6c) = -1 ENOENT (No such file or
directory)
stat64("/usr/local/lib/perl/5.8.8/Socket.pmc", 0xbf9eb05c) = -1 ENOENT
(No such file or directory)
stat64("/usr/local/lib/perl/5.8.8/Socket.pm", 0xbf9eaf6c) = -1 ENOENT
(No such file or directory)
stat64("/usr/local/share/perl/5.8.8/Socket.pmc", 0xbf9eb05c) = -1
ENOENT (No such file or directory)
stat64("/usr/local/share/perl/5.8.8/Socket.pm", 0xbf9eaf6c) = -1
ENOENT (No such file or directory)
stat64("/usr/lib/perl5/Socket.pmc", 0xbf9eb05c) = -1 ENOENT (No such
file or directory)
stat64("/usr/lib/perl5/Socket.pm", 0xbf9eaf6c) = -1 ENOENT (No such
file or directory)
stat64("/usr/share/perl5/Socket.pmc", 0xbf9eb05c) = -1 ENOENT (No such
file or directory)
stat64("/usr/share/perl5/Socket.pm", 0xbf9eaf6c) = -1 ENOENT (No such
file or directory)
stat64("/usr/lib/perl/5.8/Socket.pmc", 0xbf9eb05c) = -1 ENOENT (No
such file or directory)
stat64("/usr/lib/perl/5.8/Socket.pm", {st_mode=S_IFREG|0644,
st_size=3514, ...}) = 0
open("/usr/lib/perl/5.8/Socket.pm", O_RDONLY|O_LARGEFILE) = 8
ioctl(8, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbf9ead78) = -1 ENOTTY
(Inappropriate ioctl for device)
_llseek(8, 0, [0], SEEK_CUR) = 0
read(8, "package Socket;\n\nour($VERSION, @"..., 4096) = 3514
read(8, "", 4096) = 0
close(8) = 0
stat64("/usr/lib/perl/5.8/auto/Socket/Socket.so", {st_mode=S_IFREG|
0644, st_size=19676, ...}) = 0
stat64("/usr/lib/perl/5.8/auto/Socket/Socket.bs", {st_mode=S_IFREG|
0644, st_size=0, ...}) = 0
open("/usr/lib/perl/5.8/auto/Socket/Socket.so", O_RDONLY) = 8
read(8, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\360\16"...,
512) = 512
fstat64(8, {st_mode=S_IFREG|0644, st_size=19676, ...}) = 0
mmap2(NULL, 22644, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 8,
0) = 0xb7c03000
mmap2(0xb7c08000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|
MAP_DENYWRITE, 8, 0x4) = 0xb7c08000
close(8) = 0
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++
Process 18883 detached
Does this mean that the segfault occurred as a result of the close(8)
call - or at least that close() was the last system call prior to the
fault?
Or would the segfault have happened while executing the next call
which is not shown? (From the man page it looks as though strace will
trap signals and still print the failing call after a signal
occurs ... but I'm not sure I'm reading it correctly.)
James
------------------------------
Date: Tue, 2 Dec 2008 16:30:56 -0800 (PST)
From: James Harris <james.harris.1@googlemail.com>
Subject: Re: perl segfault - how to troubleshoot
Message-Id: <6d519e36-6547-4b86-9cbc-b22f8285aa01@t2g2000yqm.googlegroups.com>
On 2 Dec, 07:46, Tim Greer <t...@burlyhost.com> wrote:
> James Harris wrote:
> > Since a few days ago perl segfaults when running certain scripts. The
> > scripts were ok before the problem started and have not been changed.
> > I have checked my (Ubuntu) system for updates. None were made near the
> > time of the first incidence of the problem so I started looking more
> > widely.
...
> > Anyone else had similar problems recently - within a week?
>
> I doubt anyone else has had similar problems recently just due to
> running Perl (did you perform an install/upgrade of the system, any
> modules or Perl itself recently?)
No upgrades. This is really weird. From syslog the problem started on
Nov 27th at 17:56:54 with the following entry
$ gunzip -c syslog.3.gz | grep segfault | more
Nov 27 17:56:54 s01 kernel: [678797.925818] maps.pl[21703]: segfault
at 00000000 eip b7bdd004 esp bf8a1e8f error 6
Before that there was no segfault - at least for the two days the logs
go back. (I have since - I think - changed the log rotate frequency
for syslog to weekly rather than daily.)
November's system upgrades were on Nov 20, Nov 23, and Nov 29 (and the
fault started on 27th) so the only upgrade prior to the fault starting
was that on the 23rd about four days beforehand.
After that there are lots of similar segfault messages. Extracting the
list of affected modules gives
maps.pl
bbccurrentxml.pl
bbcthreedayxml.pl
optimize_mythdb.pl
tv_grab_uk_rt (a Perl script)
mythrename.pl
popcon-upload (a Perl script)
Apart from popcon the rest seem to be related to mythtv or xmltv. They
get upgraded along with the rest of the system so the last possible
changes to them should also have been approx four days prior to the
error starting.
> This sounds like a system problem.
> Run a memory checker. Run strace (or similar) on the process to see
> what it's doing. Check the running process(es), if possible (check
> top, ps, pstree, lsof, etc.) if relevant. See how much memory and CPU
> is free before running the script(s) and how much the script(s) try and
> use. Check your dmesg and system logs for error reporting, etc. and
> ensure your kernel is configured to have proper error logging. Are
> these scripts doing anything interesting, using any specific
> commands/binaries, doing anything intensive? You said some scripts seg
> fault and some don't. What types of scripts run and what types fail?
> Please provide relevant information pertaining to this potentially
> being an issue with Perl.
Thanks for all the suggestions. I'll have to check further.
James
------------------------------
Date: Tue, 2 Dec 2008 17:26:42 -0800 (PST)
From: James Harris <james.harris.1@googlemail.com>
Subject: Re: perl segfault - how to troubleshoot
Message-Id: <c7322e6e-2755-4bca-bc92-8a0a39673815@u14g2000yqg.googlegroups.com>
On 2 Dec, 21:14, Ilya Zakharevich <nospam-ab...@ilyaz.org> wrote:
...
> gdb --args `which perl` -c mythrename.pl
>
> or
>
> gdb `which perl`
> run -c mythrename.pl
Use of gdb is new to me but running the file through to the end (at
least that's what I think I have done) gives
(gdb) run
Starting program: /usr/bin/perl -c mythrename.pl
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
(no debugging symbols found)
(no debugging symbols found)
[New Thread 0xb7d568c0 (LWP 19771)]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb7d568c0 (LWP 19771)]
0xb7be0004 in boot_Socket () from /usr/lib/perl/5.8/auto/Socket/
Socket.so
(gdb)
This sounds like the fault occurred in Socket.so. The file itself has
not been updated recently
$ ls -l /usr/lib/perl/5.8/auto/Socket/Socket.so
-rw-r--r-- 1 root root 19676 2007-11-27 11:08 /usr/lib/perl/5.8/auto/
Socket/Socket.so
$
so maybe it is being passed a null pointer that it was not before. I
assume a pointer because the syslog message is
Dec 3 00:23:17 s01 kernel: [287839.008837] mythrename.pl[19643]:
segfault at 00000001 eip b7be5004 esp bfa104ff error 6
This, I think, shows the instruction pointer as b7be5004 - i.e. not
null - so presumably 00000001 is a memory address that's being passed
to Socket.so or generated within it.
I guess Socket.so is a shared library (shared object?) or similar.
Maybe gdb can be used to find out if 00000001 is being passed to
Socket.so (or a routine within it) and track down where 00000001 is
being generated.
I wish I could remember what changed, if anything, when the problem
started....
Thanks for the pointers to use gdb.
James
------------------------------
Date: Wed, 03 Dec 2008 00:30:02 +0100
From: News123 <news123@free.fr>
Subject: Re: What news reader are comp.lang.perl-ers using
Message-Id: <4935c4fa$0$6051$426a74cc@news.free.fr>
Jrgen Exner wrote:
> News123 <news123@free.fr> wrote:
>> What kind of news readers are you all using?
>
> What's the problem with simply checking the "User-Agent" header field?
>
Thanks for (and the other) the answer(s). Good idea.
Nothing's wrong with looking at UserAgnt / XNewsreader.
I just didn't think about it as my Thunderbird setup just displays the
'normal' headers by default (Subect,From,Date,Newsgroups)
bye
N
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 2025
***************************************