List Info

Thread: Bug in weak references




Bug in weak references
user name
2006-12-23 17:00:40
On Thu Feb 01 23:25:52 2001, me-01ton.iguana.be wrote:
> 
>
------------------------------------------------------------
-----
> [Please enter your report here]
> 
> perl -wle 'use Data:umper;
use WeakRef; $foo = [1]; $baz=$foo; push
>    baz, weaken($foo); print Dumper baz;
print Dumper $foo;'
> 
> baz will be unexpectedly empty.
> (PS: why do I not get a warning that I use $baz only
once ?)
> 
> [Please do not change anything below this line]
>
------------------------------------------------------------
-----
> ---
> Flags:
>     category=core
>     severity=low
> ---
> Site configuration information for perl v5.6.0:
> 
> Configured by ton at Wed Aug  9 23:24:07 CEST 2000.
> 
> Summary of my perl5 (revision 5.0 version 6 subversion
0)
>    configuration:
>   Platform:
>     osname=linux, osvers=2.4.0-test5,
archname=i686-linux
>     uname='linux quasar 2.4.0-test5 #2 sat jul 29
04:45:14 cest 2000
>    i686 unknown '
>     config_args=''
>     hint=recommended, useposix=true, d_sigaction=define
>     usethreads=undef use5005threads=undef
useithreads=undef
>    usemultiplicity=undef
>     useperlio=undef d_sfio=undef uselargefiles=undef
>     use64bitint=undef use64bitall=undef
uselongdouble=undef
>    usesocks=undef
>   Compiler:
>     cc='cc', optimize='-O2 -fomit-frame-pointer',
gccversion=egcs-
>    2.91.66 19990314 (egcs-1.1.2 release), gccosandvers=
>     cppflags='-fno-strict-aliasing
-I/usr/local/include'
>     ccflags ='-fno-strict-aliasing
-I/usr/local/include'
>     stdchar='char', d_stdstdio=define, usevfork=false
>     intsize=4, longsize=4, ptrsize=4, doublesize=8
>     d_longlong=define, longlongsize=8,
d_longdbl=define,
>    longdblsize=12
>     ivtype='long', ivsize=4, nvtype='double', nvsize=8,
Off_t='off_t',
>    lseeksize=4
>     alignbytes=4, usemymalloc=y, prototype=define
>   Linker and Libraries:
>     ld='cc', ldflags =' -L/usr/local/lib
-L/opt/gnu/lib'
>     libpth=/usr/local/lib /opt/gnu/lib /lib /usr/lib
>     libs=-lnsl -lndbm -ldl -lm -lc -lposix -lcrypt
-lutil
>     libc=/lib/libc-2.1.1.so, so=so, useshrplib=true,
>    libperl=libperl.so
>   Dynamic Linking:
>     dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef,
ccdlflags='-
>    rdynamic
-Wl,-rpath,/usr/lib/perl5/5.6.0/i686-linux/CORE'
>     cccdlflags='-fpic', lddlflags='-shared
-L/usr/local/lib
>    -L/opt/gnu/lib'
> 
> Locally applied patches:
> 
> 
> ---
> INC for perl v5.6.0:
>     /usr/lib/perl5/5.6.0/i686-linux
>     /usr/lib/perl5/5.6.0
>     /usr/lib/perl5/site_perl/5.6.0/i686-linux
>     /usr/lib/perl5/site_perl/5.6.0
>     /usr/lib/perl5/site_perl
>     .
> 
> ---
> Environment for perl v5.6.0:
>     HOME=/home/ton
>     LANG (unset)
>     LANGUAGE (unset)
>     LD_LIBRARY_PATH (unset)
>     LOGDIR (unset)
>    
PATH=/home/ton/bin.Linux:/home/ton/bin:/home/ton/bin.SampleS
etup:/usr/local/bin:/usr/local/sbin:/usr/local/jre/bin:/usr/
local/jdk116_v5/bin:/home/oracle/product/8.1.5/bin:/usr/game
s/bin:/usr/X11R6/bin:/usr/share/bin:/usr/bin:/usr/sbin:/bin:
/sbin:.
>     PERL_BADLANG (unset)
>     SHELL=/bin/bash

I'm guessing WeakRef is the predecessor to Scalar::Util. 
Replacing with
Scalar::Util, I get similar results.

steveenterprise:~> perl -wle 'use Data:umper;
use Scalar::Util
qw(weaken); $foo = [1]; $baz=$foo; push baz,
weaken($foo); print Dumper
baz; print Dumper $foo;'
$VAR1 = [];

$VAR1 = [
          1
        ];


Bug in weak references
user name
2006-12-23 17:17:12
On Sat, Dec 23, 2006 at 09:00:40AM -0800, Steve Peters via
RT wrote:
> I'm guessing WeakRef is the predecessor to
Scalar::Util.  Replacing with
> Scalar::Util, I get similar results.
> 
> steveenterprise:~> perl -wle 'use Data:umper;
use Scalar::Util
> qw(weaken); $foo = [1]; $baz=$foo; push baz,
weaken($foo); print Dumper
> baz; print Dumper $foo;'
> $VAR1 = [];
> 
> $VAR1 = [
>           1
>         ];
> 

I see nothing in the documentation for weaken() that says
what value it
returns. It appears in fact to currently return the empty
list, hence baz
is empty.

-- 
SCO - a train crash in slow motion
Bug in weak references
user name
2006-12-23 17:27:43
On 12/23/06, Steve Peters via RT <perlbug-followupperl.org> wrote:
> On Thu Feb 01 23:25:52 2001, me-01ton.iguana.be wrote:
> >
> >
------------------------------------------------------------
-----
> > [Please enter your report here]
> >
> > perl -wle 'use Data:umper;
use WeakRef; $foo = [1]; $baz=$foo; push
> >    baz, weaken($foo); print Dumper baz;
print Dumper $foo;'
> >
> > baz will be unexpectedly empty.
> > (PS: why do I not get a warning that I use $baz
only once ?)
> >
> > [Please do not change anything below this line]
> >
------------------------------------------------------------
-----
> > ---
> > Flags:
> >     category=core
> >     severity=low
> > ---
> > Site configuration information for perl v5.6.0:
> >
> > Configured by ton at Wed Aug  9 23:24:07 CEST
2000.
> >
> > Summary of my perl5 (revision 5.0 version 6
subversion 0)
> >    configuration:
> >   Platform:
> >     osname=linux, osvers=2.4.0-test5,
archname=i686-linux
> >     uname='linux quasar 2.4.0-test5 #2 sat jul 29
04:45:14 cest 2000
> >    i686 unknown '
> >     config_args=''
> >     hint=recommended, useposix=true,
d_sigaction=define
> >     usethreads=undef use5005threads=undef
useithreads=undef
> >    usemultiplicity=undef
> >     useperlio=undef d_sfio=undef
uselargefiles=undef
> >     use64bitint=undef use64bitall=undef
uselongdouble=undef
> >    usesocks=undef
> >   Compiler:
> >     cc='cc', optimize='-O2 -fomit-frame-pointer',
gccversion=egcs-
> >    2.91.66 19990314 (egcs-1.1.2 release),
gccosandvers=
> >     cppflags='-fno-strict-aliasing
-I/usr/local/include'
> >     ccflags ='-fno-strict-aliasing
-I/usr/local/include'
> >     stdchar='char', d_stdstdio=define,
usevfork=false
> >     intsize=4, longsize=4, ptrsize=4, doublesize=8
> >     d_longlong=define, longlongsize=8,
d_longdbl=define,
> >    longdblsize=12
> >     ivtype='long', ivsize=4, nvtype='double',
nvsize=8, Off_t='off_t',
> >    lseeksize=4
> >     alignbytes=4, usemymalloc=y, prototype=define
> >   Linker and Libraries:
> >     ld='cc', ldflags =' -L/usr/local/lib
-L/opt/gnu/lib'
> >     libpth=/usr/local/lib /opt/gnu/lib /lib
/usr/lib
> >     libs=-lnsl -lndbm -ldl -lm -lc -lposix -lcrypt
-lutil
> >     libc=/lib/libc-2.1.1.so, so=so,
useshrplib=true,
> >    libperl=libperl.so
> >   Dynamic Linking:
> >     dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef,
ccdlflags='-
> >    rdynamic
-Wl,-rpath,/usr/lib/perl5/5.6.0/i686-linux/CORE'
> >     cccdlflags='-fpic', lddlflags='-shared
-L/usr/local/lib
> >    -L/opt/gnu/lib'
> >
> > Locally applied patches:
> >
> >
> > ---
> > INC for perl v5.6.0:
> >     /usr/lib/perl5/5.6.0/i686-linux
> >     /usr/lib/perl5/5.6.0
> >     /usr/lib/perl5/site_perl/5.6.0/i686-linux
> >     /usr/lib/perl5/site_perl/5.6.0
> >     /usr/lib/perl5/site_perl
> >     .
> >
> > ---
> > Environment for perl v5.6.0:
> >     HOME=/home/ton
> >     LANG (unset)
> >     LANGUAGE (unset)
> >     LD_LIBRARY_PATH (unset)
> >     LOGDIR (unset)
> >
>
PATH=/home/ton/bin.Linux:/home/ton/bin:/home/ton/bin.SampleS
etup:/usr/local/bin:/usr/local/sbin:/usr/local/jre/bin:/usr/
local/jdk116_v5/bin:/home/oracle/product/8.1.5/bin:/usr/game
s/bin:/usr/X11R6/bin:/usr/share/bin:/usr/bin:/usr/sbin:/bin:
/sbin:.
> >     PERL_BADLANG (unset)
> >     SHELL=/bin/bash
>
> I'm guessing WeakRef is the predecessor to
Scalar::Util.  Replacing with
> Scalar::Util, I get similar results.
>
> steveenterprise:~> perl -wle 'use Data:umper;
use Scalar::Util
> qw(weaken); $foo = [1]; $baz=$foo; push baz,
weaken($foo); print Dumper
> baz; print Dumper $foo;'
> $VAR1 = [];
>
> $VAR1 = [
>           1
>         ];

I dont think this is a bug. Weaken isn't documented to
return a
weakref, its documented to make a given reference weak, and
returns
void in the XS code. So since the routine returns the empty
list, the
output from Dumper(baz) is correct.

Cheers,
Yves
-- 
perl -Mre=debug -e "/just|another|perl|hacker/"
Bug in weak references
user name
2006-12-23 17:30:35
On 12/23/06, Steve Peters via RT <perlbug-followupperl.org> wrote:
> On Thu Feb 01 23:25:52 2001, me-01ton.iguana.be wrote:
> >
> >
------------------------------------------------------------
-----
> > [Please enter your report here]
> >
> > perl -wle 'use Data:umper;
use WeakRef; $foo = [1]; $baz=$foo; push
> >    baz, weaken($foo); print Dumper baz;
print Dumper $foo;'
> >
> > baz will be unexpectedly empty.
> > (PS: why do I not get a warning that I use $baz
only once ?)

If theres a real bug here its the point about $baz. I guess
the reason
is because $baz and baz are used, but is that a bug?

Yves

-- 
perl -Mre=debug -e "/just|another|perl|hacker/"
[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )