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

5.20 threaded regression: boolean.pm -truth option breaks string literals in closures #14454

Closed
p5pRT opened this issue Jan 29, 2015 · 10 comments

Comments

@p5pRT
Copy link

p5pRT commented Jan 29, 2015

Migrated from rt.perl.org#123698 (status was 'rejected')

Searchable as RT123698$

@p5pRT
Copy link
Author

p5pRT commented Jan 29, 2015

From @xdg

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​:
* Test-More/test-more#546
* ingydotnet/boolean-pm#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.

@p5pRT
Copy link
Author

p5pRT commented Jan 29, 2015

From @xdg

boolean-broken.pl

@p5pRT
Copy link
Author

p5pRT commented Jan 29, 2015

From @xdg

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
  .

@p5pRT
Copy link
Author

p5pRT commented Jan 29, 2015

From @haarg

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.

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.

@p5pRT
Copy link
Author

p5pRT commented Jan 29, 2015

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

@p5pRT
Copy link
Author

p5pRT commented Jan 31, 2015

From @cpansprout

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​:
* Test-More/test-more#546
* ingydotnet/boolean-pm#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

@p5pRT
Copy link
Author

p5pRT commented Jan 31, 2015

From @jkeenan

On Sat Jan 31 14​:12​:22 2015, sprout wrote​:

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​:
* Test-More/test-more#546
* ingydotnet/boolean-pm#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 1886429) 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)

@p5pRT
Copy link
Author

p5pRT commented Feb 1, 2015

From @xdg

On Sat, Jan 31, 2015 at 5​:12 PM, Father Chrysostomos via RT <
perlbug-followup@​perl.org> wrote​:

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

@p5pRT
Copy link
Author

p5pRT commented Dec 16, 2017

From zefram@fysh.org

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

@p5pRT p5pRT closed this as completed Dec 18, 2017
@p5pRT
Copy link
Author

p5pRT commented Dec 18, 2017

@iabyn - Status changed from 'open' to 'rejected'

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