Skip Menu |
Report information
Id: 123698
Status: rejected
Priority: 0/
Queue: perl5

Owner: Nobody
Requestors: dagolden [at] cpan.org
Cc:
AdminCc:

Operating System: (no value)
PatchStatus: (no value)
Severity: low
Type: unknown
Perl Version:
  • 5.20.0
  • 5.20.1
Fixed In: (no value)



Subject: 5.20 threaded regression: boolean.pm -truth option breaks string assignment in anonymous functions
Download (untitled) / with headers
text/plain 1.1k
On Perl 5.20.X with threads, when boolean.pm uses the '-truth' option on import -- which replaces the interpreter's internal true/false values with boolean.pm objects -- we've seen a case where a string literal in an anonymous function becomes undefined, but only if a string assignment happens in the same function. The attached program demonstrates the issue. On Perl 5.18.2-threaded and Perl 5.20.0-not-threaded the output is: calling not_broken: what calling broken: what On Perl 5.20.0-threaded and 5.20.1-threaded, the output is: calling not_broken: what calling broken: Use of uninitialized value0 in print at boolean-broken.pl line 12. Discovered and discussed in these Github issues: * https://github.com/Test-More/test-more/issues/546 * https://github.com/ingydotnet/boolean-pm/issues/8 While the change in 5.21.5 to prevent unlocking read-only values (which is what boolean.pm relies on) prevents boolean.pm from doing this trick, that the problem appears unreleated to true/false values, only affects threaded 5.20.X and occurs in such a peculiar circumstance suggests that there might be a deeper bug worth investigating. My perl -V output is attached.
Subject: boolean-broken.pl
Download boolean-broken.pl
text/x-perl 261b
use strict; use warnings; use boolean -truth; my $name = 'welp'; my $not_broken = sub { print "what\n"; }; my $broken = sub { print "what\n"; my $str = $name; }; print "calling not_broken:\n"; $not_broken->(); print "calling broken:\n"; $broken->();
Subject: perl-V.txt
Download perl-V.txt
text/plain 2.9k
Summary of my perl5 (revision 5 version 20 subversion 1) configuration: Platform: osname=darwin, osvers=14.0.0, archname=darwin-thread-multi-2level uname='darwin metis.local 14.0.0 darwin kernel version 14.0.0: fri sep 19 00:26:44 pdt 2014; root:xnu-2782.1.97~2release_x86_64 x86_64 ' config_args='-Dprefix=/Users/david/.plenv/versions/20.1t -de -Dusedevel -Dusethreads -Dman1dir=none -Dman3dir=none -A'eval:scriptdir=/Users/david/.plenv/versions/20.1t/bin'' hint=recommended, useposix=true, d_sigaction=define useithreads=define, usemultiplicity=define use64bitint=define, use64bitall=define, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -I/opt/local/include', optimize='-O3', cppflags='-fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -I/opt/local/include' ccversion='', gccversion='4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)', gccosandvers='' intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 ivtype='long', ivsize=8, 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 =' -fstack-protector -L/usr/local/lib -L/opt/local/lib' libpth=/usr/local/lib /Library/Developer/CommandLineTools/usr/bin/../lib/clang/6.0/lib /Library/Developer/CommandLineTools/usr/lib /usr/lib /opt/local/lib libs=-lgdbm -ldbm -ldl -lm -lutil -lc perllibs=-ldl -lm -lutil -lc libc=, 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 -L/opt/local/lib -fstack-protector' Characteristics of this binary (from libperl): Compile-time options: HAS_TIMES MULTIPLICITY PERLIO_LAYERS PERL_DONT_CREATE_GVSV PERL_HASH_FUNC_ONE_AT_A_TIME_HARD PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP PERL_NEW_COPY_ON_WRITE PERL_PRESERVE_IVUV PERL_USE_DEVEL USE_64_BIT_ALL USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES USE_LOCALE USE_LOCALE_COLLATE USE_LOCALE_CTYPE USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF USE_REENTRANT_API Built under darwin Compiled at Jan 5 2015 12:19:43 %ENV: PERL_EXTUTILS_AUTOINSTALL="--defaultdeps" @INC: /Users/david/.plenv/versions/20.1t/lib/perl5/site_perl/5.20.1/darwin-thread-multi-2level /Users/david/.plenv/versions/20.1t/lib/perl5/site_perl/5.20.1 /Users/david/.plenv/versions/20.1t/lib/perl5/5.20.1/darwin-thread-multi-2level /Users/david/.plenv/versions/20.1t/lib/perl5/5.20.1 .
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 557b
On Thu Jan 29 07:06:25 2015, dagolden@cpan.org wrote: Show quoted text
> On Perl 5.20.X with threads, when boolean.pm uses the '-truth' option > on import -- which replaces the interpreter's internal true/false > values with boolean.pm objects -- we've seen a case where a string > literal in an anonymous function becomes undefined, but only if a > string assignment happens in the same function.
It's not related to string assignment inside the anonymous sub, it's related to the sub being a closure. This particular issue only seems to happen inside anonymous closures.
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 1.5k
On Thu Jan 29 07:06:25 2015, dagolden@cpan.org wrote: Show quoted text
> On Perl 5.20.X with threads, when boolean.pm uses the '-truth' option > on import -- which replaces the interpreter's internal true/false > values with boolean.pm objects -- we've seen a case where a string > literal in an anonymous function becomes undefined, but only if a > string assignment happens in the same function. > > The attached program demonstrates the issue. > > On Perl 5.18.2-threaded and Perl 5.20.0-not-threaded the output is: > calling not_broken: > what > calling broken: > what > > On Perl 5.20.0-threaded and 5.20.1-threaded, the output is: > calling not_broken: > what > calling broken: > Use of uninitialized value0 in print at boolean-broken.pl line 12. > > Discovered and discussed in these Github issues: > * https://github.com/Test-More/test-more/issues/546 > * https://github.com/ingydotnet/boolean-pm/issues/8 > > While the change in 5.21.5 to prevent unlocking read-only values > (which is what boolean.pm relies on) prevents boolean.pm from doing > this trick, that the problem appears unreleated to true/false values, > only affects threaded 5.20.X and occurs in such a peculiar > circumstance suggests that there might be a deeper bug worth > investigating. > > My perl -V output is attached.
I tried rigging the latest bleadperl locally to allow PL_sv_yes and PL_sv_no to be modified, and your example script worked. Is it worth pursuing this to see when the problem emerged and when it disappeared? -- Father Chrysostomos
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 2.1k
On Sat Jan 31 14:12:22 2015, sprout wrote: Show quoted text
> On Thu Jan 29 07:06:25 2015, dagolden@cpan.org wrote:
> > On Perl 5.20.X with threads, when boolean.pm uses the '-truth' option > > on import -- which replaces the interpreter's internal true/false > > values with boolean.pm objects -- we've seen a case where a string > > literal in an anonymous function becomes undefined, but only if a > > string assignment happens in the same function. > > > > The attached program demonstrates the issue. > > > > On Perl 5.18.2-threaded and Perl 5.20.0-not-threaded the output is: > > calling not_broken: > > what > > calling broken: > > what > > > > On Perl 5.20.0-threaded and 5.20.1-threaded, the output is: > > calling not_broken: > > what > > calling broken: > > Use of uninitialized value0 in print at boolean-broken.pl line > > 12. > > > > Discovered and discussed in these Github issues: > > * https://github.com/Test-More/test-more/issues/546 > > * https://github.com/ingydotnet/boolean-pm/issues/8 > > > > While the change in 5.21.5 to prevent unlocking read-only values > > (which is what boolean.pm relies on) prevents boolean.pm from doing > > this trick, that the problem appears unreleated to true/false values, > > only affects threaded 5.20.X and occurs in such a peculiar > > circumstance suggests that there might be a deeper bug worth > > investigating. > > > > My perl -V output is attached.
> > I tried rigging the latest bleadperl locally to allow PL_sv_yes and > PL_sv_no to be modified, and your example script worked. Is it worth > pursuing this to see when the problem emerged and when it disappeared?
Ingy has released boolean-0.44: https://metacpan.org/release/INGY/boolean-0.44 I built perl blead (commit 18864292b4751beee108b3b4983f9ddf2228f8ef) unthreaded and ran 'boolean-broken-pl'. It now outputs: ##### ./bin/perl ~/learn/perl/p5p/123698-boolean-broken.pl -truth not supported on Perl 5.22 or later at /home/jkeenan/perl5/lib/perl5/boolean.pm line 62. BEGIN failed--compilation aborted at /home/jkeenan/learn/perl/p5p/123698-boolean-broken.pl line 3. ##### -- James E Keenan (jkeenan@cpan.org)
Subject: Re: [perl #123698] 5.20 threaded regression: boolean.pm -truth option breaks string literals in closures
From: David Golden <dagolden [...] cpan.org>
To: Perlbug Followup <perlbug-followup [...] perl.org>
Date: Sun, 1 Feb 2015 09:26:54 -0500
Download (untitled) / with headers
text/plain 863b
On Sat, Jan 31, 2015 at 5:12 PM, Father Chrysostomos via RT <perlbug-followup@perl.org> wrote:
Show quoted text
I tried rigging the latest bleadperl locally to allow PL_sv_yes and PL_sv_no to be modified, and your example script worked.  Is it worth pursuing this to see when the problem emerged and when it disappeared?

That's good to hear.

I'm just a hedge-wizard, so I defer to the archmages as to whether this is strange enough to warrant further investigation or if it can be closed.

To Jim's point about boolean 0.44, that version includes my recent patches to deprecate '-truth' and remove tests for it.  Actually trying to use '-truth' (as the example script in the ticket does) is now fatal on newer Perls.

So replicating this for further investigation requires an older perl or boolean 0.43.

David


--
David Golden <dagolden@cpan.org> Twitter/IRC: @xdg
From: Zefram <zefram [...] fysh.org>
Subject: Re: [perl #123698] 5.20 threaded regression: boolean.pm -truth option breaks string literals in closures
To: perl5-porters [...] perl.org
Date: Sat, 16 Dec 2017 07:44:16 +0000
Download (untitled) / with headers
text/plain 223b
boolean.pm is not a core module. Its "-truth" option does something crazy that cannot be expected to not break the interpreter. We cannot be expected to support use of that option. This ticket should be closed. -zefram


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org