Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
2.07k stars 574 forks source link

segfault/error when printing re-blessed obj w/ "" overloaded #1426

Closed p5pRT closed 21 years ago

p5pRT commented 25 years ago

Migrated from rt.perl.org#2577 (status was 'resolved')

Searchable as RT2577$

p5pRT commented 25 years ago

From etienne@anonimo.isr.ist.utl.pt

Created by etienne@isr.ist.utl.pt

  perl seg faults when I give it the following script. It looks like a bug\, doesn't it?

  Etienne

====================================================================== #!/usr/bin/perl -w

## ## Make a package with an overloaded 'stringify' operator\, and see if ## I still can see the original reference type (HASH\, ARRAY ...) ##

$! = 1 ;

package Foo ; use overload '""' => sub {"ARRAY=moo-ha!ha!ha!"} ;

package main ;

$a = {} ; ## Here can tell if it's a hash\, array or whatever print "a=$a\, "\,ref($a)\,"\n\n" ;

$b = bless $a\,"Foo" ;

## Here can't anymore (btw\, $a has been blessed too) print "b=$b\, "\,ref($b)\,"\n" ; print "a=$a\, "\,ref($a)\,"\n\n" ;

## Now\, I can again $c = bless $b\, "main" ; print "c=$c\, "\,ref($c)\,"\n" ; print "b=$b\, "\,ref($b)\,"\n" ; print "a=$a\, "\,ref($a)\,"\n\n" ;

  On this machine\, the output is :

etienne@​anonimo​: perl stringify.pl a=HASH(0x80cc304)\, HASH

b=ARRAY=moo-ha!ha!ha!\, Foo a=ARRAY=moo-ha!ha!ha!\, Foo

c=main=HASH(0x80cc304)\, main b=main=HASH(0x80cc304)\, main Segmentation fault

  On another machine :

etienne@​isr​: uname -a ; perl -v ; perl stringify.pl OSF1 isr.isr.ist.utl.pt V4.0 1229 alpha

This is perl\, version 5.003_21

Copyright 1987-1997\, Larry Wall

  + suidperl security patch Perl may be copied only under the terms of either the Artistic License or the GNU General Public License\, which may be found in the Perl 5.0 source kit.

a=HASH(0x140019868)\, HASH

b=ARRAY=moo-ha!ha!ha!\, Foo a=ARRAY=moo-ha!ha!ha!\, Foo

c=main=HASH(0x140019868)\, main b=main=HASH(0x140019868)\, main Operation `.'​: no method found\,   left argument has no overloaded magic\,   right argument in overloaded package main at stringify.pl line 27.

 
 

Perl Info ``` Site configuration information for perl 5.00503: Configured by randolph at Sat Jan 22 10:22:49 MST 2000. Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration: Platform: osname=linux, osvers=2.3.39, archname=i386-linux uname='linux samwise.tausq.org 2.3.39 #1 smp wed jan 12 05:59:50 mst 2000 i686 unknown ' hint=recommended, useposix=true, d_sigaction=define usethreads=undef useperlio=undef d_sfio=undef Compiler: cc='cc', optimize='-O2 ', gccversion=2.95.2 19991109 (Debian GNU/Linux) cppflags='-Dbool=char -DHAS_BOOL -D_REENTRANT -DDEBIAN -I/usr/local/include' ccflags ='-Dbool=char -DHAS_BOOL -D_REENTRANT -DDEBIAN -I/usr/local/include' stdchar='char', d_stdstdio=undef, usevfork=false intsize=4, longsize=4, ptrsize=4, doublesize=8 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 alignbytes=4, usemymalloc=n, prototype=define Linker and Libraries: ld='cc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lnsl -lndbm -lgdbm -ldbm -ldb -ldl -lm -lc -lposix -lcrypt libc=, so=so, useshrplib=false, libperl=libperl.a Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic' cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib' Locally applied patches: @INC for perl 5.00503: /usr/lib/perl5/5.005/i386-linux /usr/lib/perl5/5.005 /usr/local/lib/site_perl/i386-linux /usr/local/lib/site_perl /usr/lib/perl5 . Environment for perl 5.00503: HOME=/home/etienne LANG (unset) LANGUAGE (unset) LC_CTYPE=pt_PT LD_LIBRARY_PATH=/usr/X11R6/lib/:/usr/openwin/lib LOGDIR (unset) PATH=.:/home/etienne/bin:/home/etienne/prog/bash:/home/etienne/prog/perl/scripts:/home/etienne/prog/perl/mail2:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/sbin:/usr/sbin:/usr/games:/usr/games/bin:/usr/local/MuPAD/share/bin PERL_BADLANG (unset) SHELL=/bin/bash ```
p5pRT commented 25 years ago

From @gsar

On Wed\, 22 Mar 2000 17​:52​:13 GMT\, etienne grossmann wrote​:

#!/usr/bin/perl -w

## ## Make a package with an overloaded 'stringify' operator\, and see if ## I still can see the original reference type (HASH\, ARRAY ...) ##

$! = 1 ;

package Foo ; use overload '""' => sub {"ARRAY=moo-ha!ha!ha!"} ;

package main ;

$a = {} ; ## Here can tell if it's a hash\, array or whatever print "a=$a\, "\,ref($a)\,"\n\n" ;

$b = bless $a\,"Foo" ;

## Here can't anymore (btw\, $a has been blessed too) print "b=$b\, "\,ref($b)\,"\n" ; print "a=$a\, "\,ref($a)\,"\n\n" ;

## Now\, I can again $c = bless $b\, "main" ; print "c=$c\, "\,ref($c)\,"\n" ; print "b=$b\, "\,ref($b)\,"\n" ; print "a=$a\, "\,ref($a)\,"\n\n" ;

FWIW\, this prints the following with 5.6.0-tobe​:

  Operation `.'​: no method found\,   left argument has no overloaded magic\,   right argument in overloaded package main at - line 22.

Sarathy gsar@​ActiveState.com

p5pRT commented 21 years ago

From The RT System itself

Cannot duplicate bug on linux 2.2.16\, appears to be a bug in that version of linux.