develooper Front page | perl.perl5.porters | Postings from April 2003

[perl #22042] CORE::readline calls overloaded <>

Thread Next
From:
perlbug-followup
Date:
April 27, 2003 10:20
Subject:
[perl #22042] CORE::readline calls overloaded <>
Message ID:
rt-22042-55979.4.621257637436@bugs6.perl.org
# New Ticket Created by  chris@lombi.mine.nu 
# Please include the string:  [perl #22042]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=22042 >


This is a bug report for perl from christian.jaeger@ethlife.ethz.ch,
generated with the help of perlbug 1.33 running under perl v5.6.1.


-----------------------------------------------------------------

The following code leads to:
Deep recursion on subroutine "Foo::xreadline" at ./foo line 30.

It looks like the problem is that CORE::readline is somehow
executing the <> operator again, which is (still) overloaded.
(Funny that in the none-overloaded case CORE::readline does
*not* call <> again?.. it would lead to the same circle, right?)

Cheers,
Christian.


#!/usr/bin/perl -w

# Sam Apr 26 21:26:48 MEST 2003
# christian.jaeger@ethlife.ethz.ch

use strict;

package Foo;
use overload '<>'=>'xreadline';
use Symbol;

sub new {
	my $class=shift;
	my $self=gensym;
	if (open $self,$_[0]) {
		bless $self,$class;
	} else {
		die $!;
	}
}
sub xreadline {
	my $self=shift;
	if (wantarray) {
		my $lines= [ CORE::readline($self) ];
		if ($!) {
			die "xreadline: $!";
		}
		@$lines
	} else {
		my $bufref= \ (scalar CORE::readline($self)); # dito
		if ($!) {
			die "xreadline: $!";
		}
		$$bufref
	}
}

package main;

my $a= new Foo "<$0";
while (<$a>) {
	chomp; print "One line: '$_'\n";
}

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=low
---
Site configuration information for perl v5.6.1:

Configured by buildd at Sat Nov 30 17:47:42 UTC 2002.

Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
  Platform:
    osname=linux, osvers=2.4.19-powerpc-smp, archname=powerpc-linux
    uname='linux voltaire 2.4.19-powerpc-smp #1 smp mon sep 9 09:11:02 edt 2002 ppc unknown '
    config_args='-Dccflags=-DDEBIAN -Dcccdlflags=-fPIC -Darchname=powerpc-linux -Dprefix=/usr -Dprivlib=/usr/share/perl/5.6.1 -Darchlib=/usr/lib/perl/5.6.1 -Dvendorprefix=/usr -Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/usr/local -Dsitelib=/usr/local/share/perl/5.6.1 -Dsitearch=/usr/local/lib/perl/5.6.1 -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dman1ext=1 -Dman3ext=3perl -Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Uusesfio -Duseshrplib -Dlibperl=libperl.so.5.6.1 -Dd_dosuid -des'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
  Compiler:
    cc='cc', ccflags ='-DDEBIAN -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-DDEBIAN -fno-strict-aliasing -I/usr/local/include'
    ccversion='', gccversion='2.95.4 20011002 (Debian prerelease)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lgdbm -ldb -ldl -lm -lc -lcrypt
    perllibs=-ldl -lm -lc -lcrypt
    libc=/lib/libc-2.2.5.so, so=so, useshrplib=true, libperl=libperl.so.5.6.1
  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 v5.6.1:
    /usr/local/lib/perl/5.6.1
    /usr/local/share/perl/5.6.1
    /usr/lib/perl5
    /usr/share/perl5
    /usr/lib/perl/5.6.1
    /usr/share/perl/5.6.1
    /usr/local/lib/site_perl
    .

---
Environment for perl v5.6.1:
    HOME=/home/chris
    LANG=de_CH
    LANGUAGE (unset)
    LC_CTYPE=de_CH
    LC_NUMERIC=C
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/chris/sbin:/home/chris/bin:/root/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/bin/X11:/usr/local/sbin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin
    PERL_BADLANG (unset)
    SHELL=/bin/bash


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About