(tye)Re: (Golf) Segfault Perl
by tye (Sage) on Apr 03, 2002 at 22:35 UTC
|
unpack"p",$^X
But if I save it to a file called "puke":
unpack$0,$0
- tye (but my friends call me "Tye") | [reply] [Watch: Dir/Any] [d/l] [select] |
|
Drop the quotes to save another character.
unpack p,$~
Works on my linux box and my windows machine.
| [reply] [Watch: Dir/Any] [d/l] |
|
| [reply] [Watch: Dir/Any] [d/l] [select] |
Re: (Golf) Segfault Perl
by Juerd (Abbot) on Apr 03, 2002 at 22:49 UTC
|
#234567
undef a
Strokes: 7
Penalty: 8 (win32, openbsd, hp-ux, mac)
Score: 15
Update - Does this only segfault on Linux systems? I thought I had a nice score, but the penalties are killing me :)
U28geW91IGNhbiBhbGwgcm90MTMgY
W5kIHBhY2soKS4gQnV0IGRvIHlvdS
ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
geW91IHNlZSBpdD8gIC0tIEp1ZXJk
| [reply] [Watch: Dir/Any] [d/l] |
|
Then it looks like we're tied:
unless, of course, someone can find a well behaving platform for this :)
MeowChow
s aamecha.s a..a\u$&owag.print | [reply] [Watch: Dir/Any] [d/l] |
|
$ perl -e '*::=%::=0'
Modification of a read-only value attempted at -e line 1.
$ perl -v
This is perl, version 5.005_02 built for PA-RISC1.1
Now I don't feel so bad about dinging Juerd. ;-)
Just call me StrokeReaper.
Update
As MeowChow and Chmrr both pointed out, the rules stipulate 5.6.1. No penalty. | [reply] [Watch: Dir/Any] [d/l] |
|
|
perl -e '*::=%::=0'
Bus error(coredump)
perl -e 'undef a'
Can't modify constant item in undef operator...
perl -v
This is perl, v5.6.1 built for IA64.ARCHREV_0-thread-multi
Binary build 631 provided by Activestate
I'll let the judges decide whether this was truly a valid test since the HW is still in the experimental stage. (Itanium running HP-UX 11.22)
| [reply] [Watch: Dir/Any] |
|
|
C:\>perl -e "undef a"
Can't modify constant item in undef operator at -e line 1, at EOF
Execution of -e aborted due to compilation errors.
C:\>perl -v
This is perl, v5.6.1 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-2001, Larry Wall
Binary build 628 provided by ActiveState Tool Corp. http://www.ActiveS
+tate.com
Built 15:41:05 Jul 4 2001
I just realized your sig is longer than your golf program. ;-)
Update
Sorry Juerd, the penalty is four strokes. No segfault under 5.00502 on HP-UX either:
$ perl -e 'undef a'
Can't modify constant item in undef operator at -e line 1, at EOF
Execution of -e aborted due to compilation errors.
$ perl -v
This is perl, version 5.005_02 built for PA-RISC1.1
Copyright 1987-1998, Larry Wall
Now I'm starting to feel bad....
Update 2
Whoops! The rules did specify 5.6.1. My bad. Just two strokes off, then.
| [reply] [Watch: Dir/Any] [d/l] [select] |
|
Sorry, there is another two stroke penalty. It doesn't work on MacPerl! And by "doesn't work" i mean it does work. And by "does work" I mean "doesn't work". Just to clarify it doesn't crash MacPerl, but MacPerl does kick me when I try to run it! Good code though. And by "Good Code" ... :)
| [reply] [Watch: Dir/Any] |
|
Hmm, this doesn't seem to segfault OpenBSD either.
MeowChow
s aamecha.s a..a\u$&owag.print | [reply] [Watch: Dir/Any] |
|
[11]: perl -e 'undef a'
[12]: perl -v
This is perl, v5.6.1 built for sun4-solaris
nice try though :-) | [reply] [Watch: Dir/Any] [d/l] |
Re: (Golf) Segfault Perl
by ariels (Curate) on Apr 04, 2002 at 12:20 UTC
|
Going through perlvar, I found this.
It segfaults, depending on how exactly Perl was compiled, and maybe a few more things...
12345678901234567
perl -e'$^M=1;$x[1<<30]=2'
Thrill as memory leaks away! Laugh as Perl attempts to recover using a single byte of memory! (Cry if your Perl was compiled without this silly feature.)
| [reply] [Watch: Dir/Any] [d/l] |
|
#2345678901
$x[1<<30]=2
U28geW91IGNhbiBhbGwgcm90MTMgY
W5kIHBhY2soKS4gQnV0IGRvIHlvdS
ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
geW91IHNlZSBpdD8gIC0tIEp1ZXJk
| [reply] [Watch: Dir/Any] [d/l] |
|
Shave another byte: $x[~0/2]=1
_____________________________________________________
Jeff[japhy]Pinyan:
Perl,
regex,
and perl
hacker, who'd like a (from-home) job
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
| [reply] [Watch: Dir/Any] [d/l] |
|
Re: (Golf) Segfault Perl
by clintp (Curate) on Apr 03, 2002 at 22:31 UTC
|
I don't personally golf, but am curious: does this also preclude signaling? kill 11,$$ isn't too creative or fun. | [reply] [Watch: Dir/Any] [d/l] |
|
Well, for one thing, that won't segfault on Win32. Not on my Win2K box with Activestate's build 628 of 5.6.1, anyway.
| [reply] [Watch: Dir/Any] |
|
Hmm... good syscall :) I entirely forgot about that, but since it doesn't crash Windows, you do get a two stroke penalty. I think Juerd's will be difficult to beat.
MeowChow
s aamecha.s a..a\u$&owag.print | [reply] [Watch: Dir/Any] |
|
| [reply] [Watch: Dir/Any] |
|
| [reply] [Watch: Dir/Any] [d/l] [select] |
(podmaster: golf) Re:Segfault Perl
by PodMaster (Abbot) on Apr 04, 2002 at 08:28 UTC
|
(podmaster: evil ;) Re: Print print Japh
########123456789
#################0123456
perl -e"$#='%.n';print 1"
Ugh, 16 chars.
perl -e"print $#='%n',1" is one char shorter, so that's 15.
$# is not experimental, but it is deprecated.
This worked for me on redhat/freebsd/Win32 (all)
Look ma', I'm on CPAN.
** The Third rule of perl club is a statement of fact: pod is sexy. | [reply] [Watch: Dir/Any] [d/l] [select] |
Re: (Golf) Segfault Perl
by petral (Curate) on Apr 04, 2002 at 01:07 UTC
|
If you want to really get fussy, certain unnamed entries produce bus errors (8a) not segmentation faults (8b), but I'm not going to bring it up.
  p | [reply] [Watch: Dir/Any] |
Re: (Golf) Segfault Perl
by Anarion (Hermit) on Apr 05, 2002 at 10:47 UTC
|
anarion@anarion:~/perl$ perl -e'read A,A'
Segmentation fault
This is perl, v5.6.1 built for i386-linux
$anarion=\$anarion;
s==q^QBY_^=,$_^=$[x7,print
| [reply] [Watch: Dir/Any] [d/l] |
|
<tsm:rylesl>|/home/rylesl > perl -e'read A,A'
Not enough arguments for read at -e line 1, at EOF
Execution of -e aborted due to compilation errors.
<tsm:rylesl>|/home/rylesl > perl -v
This is perl, v5.6.1 built for aix
perl -e 'print reverse qw/o b n a e s/;' | [reply] [Watch: Dir/Any] [d/l] |
|
C:\scripts>perl -e"read A,A"
Can't modify constant item in read at -e line 1, at EOF
Not enough arguments for read at -e line 1, at EOF
Execution of -e aborted due to compilation errors.
C:\scripts>perl -v
This is perl, v5.6.1 built for MSWin32-x86-multi-thread
| [reply] [Watch: Dir/Any] [d/l] |
Re: (Golf) Segfault Perl
by mem (Acolyte) on Apr 05, 2002 at 07:35 UTC
|
| [reply] [Watch: Dir/Any] [d/l] |
|
Nice, but so far, I can only get this to segfault linux (neither OpenBSD nor Windows misbehave sufficiently). I suspect this is the same bug as Juerd's "undef a".
MeowChow
s aamecha.s a..a\u$&owag.print | [reply] [Watch: Dir/Any] |
|
admin@heaven:~$ perl -e'(d,d)=0'
admin@heaven:~$ perl -v
This is perl, v5.6.1 built for i386-freebsd
2 stroke penalty...
U28geW91IGNhbiBhbGwgcm90MTMgY
W5kIHBhY2soKS4gQnV0IGRvIHlvdS
ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
geW91IHNlZSBpdD8gIC0tIEp1ZXJk
| [reply] [Watch: Dir/Any] [d/l] |
|
<tsm:rylesl>|/home/rylesl > perl -e'(d,d)=0'
Memory fault(coredump)
<tsm:rylesl>|/home/rylesl > perl -v
This is perl, v5.6.1 built for aix
perl -e 'print reverse qw/o b n a e s/;' | [reply] [Watch: Dir/Any] [d/l] |
|
[4]: perl -e '(d,d)=0'
[5]: perl -v
This is perl, v5.6.1 built for sun4-solaris
| [reply] [Watch: Dir/Any] [d/l] |