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.
In reply to Segmentation fault when doing /match/ and $_=$1 by ambrus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |