Perl / perl5

đŸȘ The Perl programming language
https://dev.perl.org/perl5/
Other
1.98k stars 559 forks source link

Unexpected: Use of freed value in iteration at ... #15447

Open p5pRT opened 8 years ago

p5pRT commented 8 years ago

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

Searchable as RT128634$

p5pRT commented 8 years ago

From @KES777

Created by @KES777

$ cat example.pl my $hash = { a => {}\, b => {} }; for my $value ( values %$hash ) {   delete $hash->{ b };   print $value; #\<\<\<\<\< Use of freed value in iteration at ... }

$ perl example.pl Use of freed value in iteration at iter_free line 4. HASH(0x1590178) $ perl example.pl HASH(0x17e6d38)HASH(0x17d1178)

That is not expected to get different behavior for two runs

Maybe related to​: https://rt.perl.org/Public/Bug/Display.html?id=85026 which was closed as of 5.14.1 https://metacpan.org/pod/distribution/perl/pod/perl5141delta.pod#Bug-Fixes * A bug has been fixed that would cause a "Use of freed value in iteration"   error if the next two hash elements that would be iterated over are deleted. [perl #85026]

https://rt.perl.org/Public/Bug/Display.html?id=89548 https://rt.perl.org/Public/Bug/Display.html?id=77706

Perl Info ``` Flags: category=core severity=low Site configuration information for perl 5.25.1: Configured by kes at Sun Jun 5 17:16:28 EEST 2016. Summary of my perl5 (revision 5 version 25 subversion 1) configuration: Platform: osname=linux, osvers=3.13.0-37-generic, archname=x86_64-linux uname='linux keswork 3.13.0-37-generic #64-ubuntu smp mon sep 22 21:28:38 utc 2014 x86_64 x86_64 x86_64 gnulinux ' config_args='-de -Dprefix=/home/kes/perl5/perlbrew/perls/perl-5.25.1 -Dusedevel -Aeval:scriptdir=/home/kes/perl5/perlbrew/perls/perl-5.25.1/bin' hint=recommended, useposix=true, d_sigaction=define useithreads=undef, usemultiplicity=undef use64bitint=define, use64bitall=define, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O2', cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include' ccversion='', gccversion='4.8.4', gccosandvers='' intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678, doublekind=3 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16, longdblkind=3 ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='cc', ldflags =' -fstack-protector -L/usr/local/lib' libpth=/usr/local/lib /usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed /usr/include/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib libs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc libc=libc-2.19.so, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='2.19' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E' cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector' Locally applied patches: Devel::PatchPerl 1.38 @INC for perl 5.25.1: /home/kes/perl5/perlbrew/perls/perl-5.25.1/lib/site_perl/5.25.1/x86_64-linux /home/kes/perl5/perlbrew/perls/perl-5.25.1/lib/site_perl/5.25.1 /home/kes/perl5/perlbrew/perls/perl-5.25.1/lib/5.25.1/x86_64-linux /home/kes/perl5/perlbrew/perls/perl-5.25.1/lib/5.25.1 . Environment for perl 5.25.1: HOME=/home/kes LANG=ru_UA.UTF-8 LANGUAGE=en LC_MESSAGES=en_US.UTF-8 LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/home/kes/perl5/perlbrew/bin:/home/kes/perl5/perlbrew/perls/perl-5.25.1/bin:/home/kes/perl5/bin:/home/kes/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games PERLBREW=command perlbrew PERLBREW_BASHRC_VERSION=0.75 PERLBREW_HOME=/home/kes/.perlbrew PERLBREW_MANPATH=/home/kes/perl5/perlbrew/perls/perl-5.25.1/man PERLBREW_PATH=/home/kes/perl5/perlbrew/bin:/home/kes/perl5/perlbrew/perls/perl-5.25.1/bin PERLBREW_PERL=perl-5.25.1 PERLBREW_ROOT=/home/kes/perl5/perlbrew PERLBREW_VERSION=0.75 PERL_BADLANG (unset) SHELL=/bin/bash ```
p5pRT commented 8 years ago

From @cpansprout

On Sat Jul 16 10​:00​:14 2016\, kes-kes@​yandex.ru wrote​:

$ cat example.pl my $hash = { a => {}\, b => {} }; for my $value ( values %$hash ) { delete $hash->{ b }; print $value; #\<\<\<\<\< Use of freed value in iteration at ... }

$ perl example.pl Use of freed value in iteration at iter_free line 4. HASH(0x1590178) $ perl example.pl HASH(0x17e6d38)HASH(0x17d1178)

That is not expected to get different behavior for two runs

Maybe related to​: https://rt.perl.org/Public/Bug/Display.html?id=85026 which was closed as of 5.14.1 https://metacpan.org/pod/distribution/perl/pod/perl5141delta.pod#Bug- Fixes * A bug has been fixed that would cause a "Use of freed value in iteration" error if the next two hash elements that would be iterated over are deleted. [perl #85026]

No\, it’s not related to that.

https://rt.perl.org/Public/Bug/Display.html?id=89548 https://rt.perl.org/Public/Bug/Display.html?id=77706

That’s exactly it. The stack holds no reference counts and ‘delete $hash->{b}’ frees one of the return values of ‘values’ which is on the stack on items that ‘for’ is iterating through.

--

Father Chrysostomos

p5pRT commented 8 years ago

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