ambrus has asked for the wisdom of the Perl Monks concerning the following question:
Dear fellow monks,
I get a Segmentation Fault (SIGSEGV) from perl when running the below snippet.
I see nothing in this code why it should do that. Do you have any explanation.
perl -we '$_ = ""; $/ = \4096; while (defined($_.=<>)) { /([\x20-\x7e] +*\z)/ and $_ = $1; }' /dev/urandom
As its input is random, I sometimes have to wait more to get the segv, somtimes I get it very soon. This is a stripped-down example, so it does not do any useful. When giving it a finite file instead of /dev/random it migth get in an infinite busy-loop when giving it a finite file instead of /dev/random (which is the expected behaiviour) or it might segfault.
I am running perl v5.8.5 built for i686-linux, but I can get the same error from v5.8.2 too.
Update: removed a line break from the command. Probably does not matter at all, but you can never now in such cases. Update: please report whether you can reproduce the segfault at all, even if you have no idea why it happens. Maybe it's just a fault on my side.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Segmentation fault when doing /match/ and $_=$1
by diotalevi (Canon) on Sep 28, 2004 at 19:15 UTC | |
|
Re: Segmentation fault when doing /match/ and $_=$1
by graff (Chancellor) on Sep 29, 2004 at 01:01 UTC | |
|
Re: Segmentation fault when doing /match/ and $_=$1
by hv (Prior) on Sep 29, 2004 at 12:04 UTC | |
|
Re: Segmentation fault when doing /match/ and $_=$1
by hossman (Prior) on Sep 28, 2004 at 20:26 UTC | |
|
Re: Segmentation fault when doing /match/ and $_=$1
by BrowserUk (Patriarch) on Sep 28, 2004 at 17:04 UTC |