Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistency in caller() returned values #8939

Open
p5pRT opened this issue Jun 21, 2007 · 3 comments
Open

Inconsistency in caller() returned values #8939

p5pRT opened this issue Jun 21, 2007 · 3 comments

Comments

@p5pRT
Copy link

p5pRT commented Jun 21, 2007

Migrated from rt.perl.org#43279 (status was 'open')

Searchable as RT43279$

@p5pRT
Copy link
Author

p5pRT commented Jun 21, 2007

From Bernhard.Wimmer@qimonda.com

There is an inconsistency in which line number is returned by the
caller().
Example​:

1 sub a {
2 my ($pack, $file, $line, $sub) = caller(0);
3 print "sub a() called from $sub/$line\n";
4 return 2;
5 }
6
7 my $i=0;
8 if (1) {
9 for (; $i<a(); ) {
10 $i++;
11 }
12 }

Perl 5.6.1 produces​:
sub a() called from main​::a/8
sub a() called from main​::a/9
sub a() called from main​::a/9

Perl 5.8.8 produces​:
sub a() called from main​::a/8
sub a() called from main​::a/10
sub a() called from main​::a/10

Problem​:
The subroutine a() is called three times in line 9. However, the first
return values from caller() differ from the following ones.

I don't know the root cause for this behaviour, but it would be nice if
the bug could be fixed.

Thanks and best regards
Bernhard



  Platform​:
  osname=solaris, osvers=2.8, archname=sun4-solaris
  uname='sunos sonne 5.8 generic_117350-43 sun4u sparc sunw,ultra-60 '
  config_args='-Dprefix=/opt/perl/5.8.8-32bit'
  hint=recommended, useposix=true, d_sigaction=define
  usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
  useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
  use64bitint=undef use64bitall=undef uselongdouble=undef
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='cc', ccflags =' -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
  optimize='-O',
  cppflags=''
  ccversion='Sun C 5.8 2005/10/13', gccversion='', gccosandvers=''
  intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
  ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
  alignbytes=8, prototype=define
  Linker and Libraries​:
  ld='cc', ldflags =' -L/usr/lib -L/usr/ccs/lib
-L/opt/sunstudio/11.0/prod/lib/v8plus -L/opt/sunstudio/11.0/prod/lib
-L/lib '
  libpth=/usr/lib /usr/ccs/lib /opt/sunstudio/11.0/prod/lib/v8plus
/opt/sunstudio/11.0/prod/lib /lib
  libs=-lsocket -lnsl -ldl -lm -lc
  perllibs=-lsocket -lnsl -ldl -lm -lc
  libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
  gnulibc_version=''
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
  cccdlflags='-KPIC', lddlflags='-G -L/usr/lib -L/usr/ccs/lib
-L/opt/sunstudio/11.0/prod/lib/v8plus -L/opt/sunstudio/11.0/prod/lib
-L/lib'

Characteristics of this binary (from libperl)​:
  Compile-time options​: PERL_MALLOC_WRAP USE_LARGE_FILES USE_PERLIO
  Built under solaris
  Compiled at Jan 9 2007 14​:53​:04
  @​INC​:
  /opt/perl/5.8.8-32bit/lib/5.8.8/sun4-solaris
  /opt/perl/5.8.8-32bit/lib/5.8.8
  /opt/perl/5.8.8-32bit/lib/site_perl/5.8.8/sun4-solaris
  /opt/perl/5.8.8-32bit/lib/site_perl/5.8.8
  /opt/perl/5.8.8-32bit/lib/site_perl

@p5pRT
Copy link
Author

p5pRT commented Jun 21, 2007

From @jbenjore

On 6/21/07, via RT Bernhard. Wimmer @​ qimonda. com
<perlbug-followup@​perl.org> wrote​:

# New Ticket Created by Bernhard.Wimmer@​qimonda.com
# Please include the string​: [perl #43279]
# in the subject line of all future correspondence about this issue.
# <URL​: http​://rt.perl.org/rt3/Ticket/Display.html?id=43279 >

There is an inconsistency in which line number is returned by the
caller().
Example​:

1 sub a {
2 my ($pack, $file, $line, $sub) = caller(0);
3 print "sub a() called from $sub/$line\n";
4 return 2;
5 }
6
7 my $i=0;
8 if (1) {
9 for (; $i<a(); ) {
10 $i++;
11 }
12 }

Perl 5.6.1 produces​:
sub a() called from main​::a/8
sub a() called from main​::a/9
sub a() called from main​::a/9

Perl 5.8.8 produces​:
sub a() called from main​::a/8
sub a() called from main​::a/10
sub a() called from main​::a/10

Problem​:
The subroutine a() is called three times in line 9. However, the first
return values from caller() differ from the following ones.

I don't know the root cause for this behaviour, but it would be nice if
the bug could be fixed.

This problem is that that the line number for the code in the
conditional is not "on a line" but gets its line from the previous
line. Once the interpreter has entered the main block of the loop,
that starts the current line again.

perl -MO=Concise,-exec -e 'for(;$i<a();){$i++}'
1 <0> enter

# The line outside the for(;;)
2 <;> nextstate(main 2 -e​:1) v

3 <{> enterloop(next->7 last->e redo->4) v

# The conditional. The last seen line was outside the loop.
8 <#> gvsv[*i] s
9 <0> pushmark s
a <#> gv[*a] s/EARLYCV
b <1> entersub[t3] sKS/TARG,1
c <2> lt sK/2
d <|> and(other->4) vK/1

# The body of the loop. Now another line is observed. Notice the "goto."
4 <;> nextstate(main 1 -e​:1) v
5 <#> gvsv[*i] s
6 <1> preinc[t5] vK/1
7 <0> unstack v
  goto 8
e <2> leaveloop vK/2
f <@​> leave[1 ref] vKP/REFC
-e syntax OK

This can perhaps be corrected by introducing a nextstate op into the
conditional. I don't know why this has never been changed.

Josh

@p5pRT
Copy link
Author

p5pRT commented Jun 21, 2007

The RT System itself - Status changed from 'new' to 'open'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants