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

LVALUE refs have an incorrect refcount #9084

Closed
p5pRT opened this issue Oct 27, 2007 · 3 comments
Closed

LVALUE refs have an incorrect refcount #9084

p5pRT opened this issue Oct 27, 2007 · 3 comments

Comments

@p5pRT
Copy link

p5pRT commented Oct 27, 2007

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

Searchable as RT46943$

@p5pRT
Copy link
Author

p5pRT commented Oct 27, 2007

From @cpansprout

I don't seem to be able to weaken LVALUE refs​:
$ perl -MScalar​::Util=weaken -le '$_ = \substr$y,0; print; weaken $_;
print'
LVALUE(0x1801d88)
LVALUE(0x1801d88)

(Although 'isweak' claims it's weak.)

But if I execute the same compiled code more than once​:
$ perl -MScalar​::Util=weaken -le '$x = \substr$y,0 for 1..2; print
$x; weaken $x; print $x'
LVALUE(0x1801d4c)
<blank line>

It turns out the the first one has the wrong refcount​:
$ perl -le 'for (1..5){ push @​@​, \substr my $y,0; print
Internals​::SvREFCNT(${$@​[-1]}), " $@​[-1]" }'
2 LVALUE(0x1801dd0)
1 LVALUE(0x1801440)
1 LVALUE(0x1801e30)
1 LVALUE(0x1801e54)
1 LVALUE(0x1801e78)

(Without pushing it onto a var outside the block, it reuses the
reference,
alternating between two of them​:)
$ perl -le 'for (1..5){ $x = \substr my $y,0; print
Internals​::SvREFCNT($$x), " $x" }'
SvREFCNT($$x), " $x" }'
2 LVALUE(0x1801dd0)
1 LVALUE(0x180129c)
2 LVALUE(0x1801dd0)
1 LVALUE(0x180129c)
2 LVALUE(0x1801dd0)

If I weaken it, it forces it to use the same one again next time​:
$ perl -MScalar​::Util=weaken -le 'for (1..5){ push @​@​, \substr my $y,
0; print Internals​::SvREFCNT(${$@​[-1]}), " $@​[-1]" ; weaken $@​[-1] }'
2 LVALUE(0x1801db8)
2 LVALUE(0x1801db8)
2 LVALUE(0x1801db8)
2 LVALUE(0x1801db8)
2 LVALUE(0x1801db8)
$ perl -MScalar​::Util=weaken -le 'for (1..5){ push @​@​, \substr my $y,
0; print Internals​::SvREFCNT(${$@​[-1]}), " $@​[-1]" ; weaken $@​[-1] if
$_ %2}'
2 LVALUE(0x1801db8)
2 LVALUE(0x1801db8)
1 LVALUE(0x1801440)
1 LVALUE(0x1801440)
1 LVALUE(0x1818e78)

This occurs also in perl 5.8.8.

I hope that's enough information to help solve the problem. I
encountered the same thing with 'vec', but I haven't looked into it
in detail. (I wonder what pos() does.)

Father Chrysostomos


Flags​:
  category=core
  severity=low


This perlbug was built using Perl 5.10.0 - Mon Sep 24 10​:10​:11 PDT 2007
It is being executed now by Perl 5.10.0 - Sat Oct 6 16​:48​:24 PDT 2007.

Site configuration information for perl 5.10.0​:

Configured by neo at Sat Oct 6 16​:48​:24 PDT 2007.

Summary of my perl5 (revision 5 version 10 subversion 0 patch 32056)
configuration​:
  Platform​:
  osname=darwin, osvers=8.8.0, archname=darwin-2level
  uname='darwin treebeard.local 8.8.0 darwin kernel version 8.8.0​:
fri sep 8 17​:18​:57 pdt 2006; root​:xnu-792.12.6.obj~1release_ppc power
macintosh powerpc '
  config_args='-de'
  hint=recommended, useposix=true, d_sigaction=define
  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 ='-fno-common -DPERL_DARWIN -no-cpp-precomp -
fno-strict-aliasing -pipe -I/usr/local/include',
  optimize='-O3',
  cppflags='-no-cpp-precomp -fno-common -DPERL_DARWIN -no-cpp-
precomp -fno-strict-aliasing -pipe -I/usr/local/include'
  ccversion='', gccversion='4.0.0 20041026 (Apple Computer, Inc.
build 4061)', gccosandvers='darwin8'
  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='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -L/usr/
local/lib'
  libpth=/usr/local/lib /usr/lib
  libs=-ldbm -ldl -lm -lc
  perllibs=-ldl -lm -lc
  libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false,
libperl=libperl.a
  gnulibc_version=''
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
  cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/
usr/local/lib'

Locally applied patches​:
  DEVEL


@​INC for perl 5.10.0​:
  /usr/local/lib/perl5/5.9.5/darwin-2level
  /usr/local/lib/perl5/5.9.5
  /usr/local/lib/perl5/site_perl/5.9.5/darwin-2level
  /usr/local/lib/perl5/site_perl/5.9.5
  .


Environment for perl 5.10.0​:
  DYLD_LIBRARY_PATH (unset)
  HOME=/Users/neo
  LANG (unset)
  LANGUAGE (unset)
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)
  PATH=/bin​:/sbin​:/usr/bin​:/usr/sbin​:/usr/TeX/bin/powerpc-
darwin6.8​:/usr/local/bin
  PERL_BADLANG (unset)
  SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Apr 6, 2011

From @cpansprout

This appears to have been resolved by commit 2154eca, so it was
presumably related to, or the same bug as, #67838.

@p5pRT
Copy link
Author

p5pRT commented Apr 6, 2011

@cpansprout - Status changed from 'new' to 'resolved'

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

No branches or pull requests

1 participant