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

[PATCH] ExtUtils::ParseXS: use literals for VERSION in 'use Module VERSION' #16451

Closed
p5pRT opened this issue Mar 4, 2018 · 14 comments
Closed

Comments

@p5pRT
Copy link

p5pRT commented Mar 4, 2018

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

Searchable as RT132935$

@p5pRT
Copy link
Author

p5pRT commented Mar 4, 2018

From @skaji

Created by @skaji

Currently in ExtUtils​::ParseXS, the version check does not work
because we use variables for VERSION​:

```
our $VERSION;
BEGIN {
  $VERSION = '3.38';
}
use ExtUtils​::ParseXS​::Constants $VERSION;
```

We must use literals for VERSION.
A patch for this is attached to this e-mail.

Perl Info

Flags:
    category=library
    severity=low
    module=ExtUtils::ParseXS

Site configuration information for perl 5.26.1:

Configured by travis at Sat Sep 30 13:44:01 UTC 2017.

Summary of my perl5 (revision 5 version 26 subversion 1) configuration:
   
  Platform:
    osname=darwin
    osvers=15.6.0
    archname=darwin-2level
    uname='darwin traviss-mac-1207.local 15.6.0 darwin kernel version 15.6.0: mon aug 29 20:21:34 pdt 2016; root:xnu-3248.60.11~1release_x86_64 x86_64 '
    config_args='-Dprefix=/opt/perl -Duserelocatableinc -Dman1dir=none -Dman3dir=none -DDEBUGGING=-g -des'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=undef
    usemultiplicity=undef
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
    bincompat5005=undef
  Compiler:
    cc='cc'
    ccflags ='-fno-common -DPERL_DARWIN -mmacosx-version-min=10.11 -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -DPERL_USE_SAFE_PUTENV'
    optimize='-O3 -g'
    cppflags='-fno-common -DPERL_DARWIN -mmacosx-version-min=10.11 -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    ccversion=''
    gccversion='4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)'
    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 =' -mmacosx-version-min=10.11 -fstack-protector-strong -L/usr/local/lib'
    libpth=/usr/local/lib /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.3.0/lib /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib /usr/lib
    libs=-lpthread -ldbm -ldl -lm -lutil -lc
    perllibs=-lpthread -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=' -mmacosx-version-min=10.11 -bundle -undefined dynamic_lookup -L/usr/local/lib -fstack-protector-strong'

Locally applied patches:
    Devel::PatchPerl 1.48


@INC for perl 5.26.1:
    /Users/skaji/env/plenv/versions/relocatable-5.26.1.1/lib/site_perl/5.26.1/darwin-2level
    /Users/skaji/env/plenv/versions/relocatable-5.26.1.1/lib/site_perl/5.26.1
    /Users/skaji/env/plenv/versions/relocatable-5.26.1.1/lib/5.26.1/darwin-2level
    /Users/skaji/env/plenv/versions/relocatable-5.26.1.1/lib/5.26.1


Environment for perl 5.26.1:
    DYLD_LIBRARY_PATH (unset)
    HOME=/Users/skaji
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LC_ALL=en_US.UTF-8
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
   
PATH=/Users/skaji/env/plenv/versions/relocatable-5.26.1.1/bin:/Users/skaji/env/plenv/libexec:/Users/skaji/env/plenv/plugins/perl-build/bin:/Users/skaji/env/plenv/plugins/plenv-contrib/bin:/Users/skaji/env/plenv/plugins/plenv-download/bin:/Users/skaji/env/plenv/plugins/plenv-freeze/bin:/Users/skaji/env/plenv/plugins/plenv-reset/bin:/Users/skaji/env/plenv/plugins/plenv-update/bin:/Users/skaji/env/pyenv/shims:/Users/skaji/env/rbenv/shims:/Users/skaji/env/plenv/shims:/Users/skaji/env/rakudobrew/moar-master/install/share/perl6/site/bin:/Users/skaji/env/rakudobrew/moar-master/install/bin:/Users/skaji/env/go/bin:/Users/skaji/env/node/bin:/Users/skaji/env/plenv/bin:/Users/skaji/env/pyenv/bin:/Users/skaji/env/rbenv/bin:/Users/skaji/bin:/Users/skaji/dotfiles/bin:/usr/local/opt/gnu-tar/libexec/gnubin:/usr/local/opt/coreutils/libexec/gnubin:/opt/vagrant/bin:/usr/local/heroku/bin:/usr/local/bin:/usr/sbin:/sbin:/usr/bin:/bin:/opt/X11/bin:/Applications/Wireshark.app/Contents/MacOS
    PERLDOC=-MPod::Text::Color::Delight
    PERL_BADLANG (unset)
    PERL_CPAN_MIRROR_TINY_BASE=/Users/skaji/.perl-cpm/cache
    PERL_STRICTURES_EXTRA=1
    SHELL=/usr/local/bin/zsh

@p5pRT
Copy link
Author

p5pRT commented Mar 4, 2018

From @skaji

0001-ExtUtils-ParseXS-use-literals-for-VERSION-in-use-Mod.patch
From 8be55465b93598ec391b65984f862e86d6ff85bd Mon Sep 17 00:00:00 2001
From: Shoichi Kaji <skaji@cpan.org>
Date: Sun, 4 Mar 2018 15:41:51 +0900
Subject: [PATCH] ExtUtils::ParseXS: use literals for VERSION in 'use Module
 VERSION'

---
 dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm b/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm
index 16359ccbce..444a55de3d 100644
--- a/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm
+++ b/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm
@@ -9,14 +9,11 @@ use File::Basename;
 use File::Spec;
 use Symbol;
 
-our $VERSION;
-BEGIN {
-  $VERSION = '3.38';
-}
-use ExtUtils::ParseXS::Constants $VERSION;
-use ExtUtils::ParseXS::CountLines $VERSION;
-use ExtUtils::ParseXS::Utilities $VERSION;
-use ExtUtils::ParseXS::Eval $VERSION;
+our $VERSION = '3.38';
+use ExtUtils::ParseXS::Constants 3.38;
+use ExtUtils::ParseXS::CountLines 3.38;
+use ExtUtils::ParseXS::Utilities 3.38;
+use ExtUtils::ParseXS::Eval 3.38;
 $VERSION = eval $VERSION if $VERSION =~ /_/;
 
 use ExtUtils::ParseXS::Utilities qw(
-- 
2.16.2

@p5pRT
Copy link
Author

p5pRT commented Mar 5, 2018

From @jkeenan

On Sun, 04 Mar 2018 07​:10​:18 GMT, skaji@​outlook.com wrote​:

This is a bug report for perl from skaji@​outlook.com,
generated with the help of perlbug 1.40 running under perl 5.26.1.

-----------------------------------------------------------------
[Please describe your issue here]

Currently in ExtUtils​::ParseXS, the version check does not work
because we use variables for VERSION​:

```
our $VERSION;
BEGIN {
$VERSION = '3.38';
}
use ExtUtils​::ParseXS​::Constants $VERSION;
```

We must use literals for VERSION.
A patch for this is attached to this e-mail.

Please see the explanation provided by Steffen Mueller in commit 71a65ad back in 2011​:

#####
ExtUtils​::ParseXS​: Explicitly require current version of submodules

Since there have been certain problems with parts of ExtUtils​::ParseXS being shadowed by older installations of the module, this commit adds an explicit $VERSION to all submodules and requires them to have the same version as the main module. This doesn't actually fix any problem, but makes them more apparent as early as possible instead of failing with obscure compile errors when bad C is generated from the original XS.
#####

Thank you very much.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Mar 5, 2018

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

@p5pRT
Copy link
Author

p5pRT commented Mar 5, 2018

From @cpansprout

On Sun, 04 Mar 2018 18​:24​:12 -0800, jkeenan wrote​:

On Sun, 04 Mar 2018 07​:10​:18 GMT, skaji@​outlook.com wrote​:

This is a bug report for perl from skaji@​outlook.com,
generated with the help of perlbug 1.40 running under perl 5.26.1.

-----------------------------------------------------------------
[Please describe your issue here]

Currently in ExtUtils​::ParseXS, the version check does not work
because we use variables for VERSION​:

```
our $VERSION;
BEGIN {
$VERSION = '3.38';
}
use ExtUtils​::ParseXS​::Constants $VERSION;
```

We must use literals for VERSION.
A patch for this is attached to this e-mail.

Please see the explanation provided by Steffen Mueller in commit
71a65ad back in 2011​:

#####
ExtUtils​::ParseXS​: Explicitly require current version of submodules

Since there have been certain problems with parts of ExtUtils​::ParseXS
being shadowed by older installations of the module, this commit adds
an explicit $VERSION to all submodules and requires them to have the
same version as the main module. This doesn't actually fix any
problem, but makes them more apparent as early as possible instead of
failing with obscure compile errors when bad C is generated from the
original XS.
#####

That explains why version checks are a good idea. It does not justify the fact that that commit failed to add any version checks.

This​:

  use ExtUtils​::ParseXS​::Constants $VERSION;

is equivalent to​:

BEGIN {
  require ExtUtils​::ParseXS​::Constants;
  'ExtUtils​::ParseXS​::Constants'->import;
}

And a call to a nonexistent import method is silently ignored.

I don’t like the patch, because of the maintenance burden it creates (multiple numbers to update). I wouldn’t mind a patch that calls ->VERSION($VERSION) explicitly in a BEGIN block.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Mar 5, 2018

From @skaji

Hi James,

Thanks for your reply.
I think I understand ExtUtils​::ParseXS explicitly require current version of submodules. The point here is that the version check does not work.

Hi Father,

Tanks for your comment.

I don’t like the patch, because of the maintenance burden it creates (multiple numbers to update). I wouldn’t mind a patch that calls ->VERSION($VERSION) explicitly in a BEGIN block.

I understand. I added another patch which call require() and ->VERSION() in BEGIN block.

On Sun, 04 Mar 2018 18​:56​:17 -0800, sprout wrote​:

On Sun, 04 Mar 2018 18​:24​:12 -0800, jkeenan wrote​:

On Sun, 04 Mar 2018 07​:10​:18 GMT, skaji@​outlook.com wrote​:

This is a bug report for perl from skaji@​outlook.com,
generated with the help of perlbug 1.40 running under perl 5.26.1.

-----------------------------------------------------------------
[Please describe your issue here]

Currently in ExtUtils​::ParseXS, the version check does not work
because we use variables for VERSION​:

```
our $VERSION;
BEGIN {
$VERSION = '3.38';
}
use ExtUtils​::ParseXS​::Constants $VERSION;
```

We must use literals for VERSION.
A patch for this is attached to this e-mail.

Please see the explanation provided by Steffen Mueller in commit
71a65ad back in 2011​:

#####
ExtUtils​::ParseXS​: Explicitly require current version of submodules

Since there have been certain problems with parts of
ExtUtils​::ParseXS
being shadowed by older installations of the module, this commit adds
an explicit $VERSION to all submodules and requires them to have the
same version as the main module. This doesn't actually fix any
problem, but makes them more apparent as early as possible instead of
failing with obscure compile errors when bad C is generated from the
original XS.
#####

That explains why version checks are a good idea. It does not justify
the fact that that commit failed to add any version checks.

This​:

use ExtUtils​::ParseXS​::Constants $VERSION;

is equivalent to​:

BEGIN {
require ExtUtils​::ParseXS​::Constants;
'ExtUtils​::ParseXS​::Constants'->import;
}

And a call to a nonexistent import method is silently ignored.

I don’t like the patch, because of the maintenance burden it creates
(multiple numbers to update). I wouldn’t mind a patch that calls
->VERSION($VERSION) explicitly in a BEGIN block.

@p5pRT
Copy link
Author

p5pRT commented Mar 5, 2018

From @skaji

0001-RT-132935-correctly-check-VERSIONs-in-ExtUtils-Parse.patch
From 62ebd127e4da7c5d982e3da3befe5931915d83ad Mon Sep 17 00:00:00 2001
From: Shoichi Kaji <skaji@cpan.org>
Date: Mon, 5 Mar 2018 23:25:49 +0900
Subject: [PATCH] RT #132935: correctly check VERSIONs in ExtUtils::ParseXS

The following version check does not work correctly:

BEGIN { $VERSION = '3.38' }
use ExtUtils::ParseXS::Constants $VERSION;

The reason is that we must use version "literals",
not "variables" in `use Module VERSION`.
For the sake of ease of maintenance,
we use "require" and "->VERSION", instead of "use" here.
---
 dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm b/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm
index 16359ccbce..a36cf14c06 100644
--- a/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm
+++ b/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm
@@ -12,11 +12,11 @@ use Symbol;
 our $VERSION;
 BEGIN {
   $VERSION = '3.38';
+  require ExtUtils::ParseXS::Constants; ExtUtils::ParseXS::Constants->VERSION($VERSION);
+  require ExtUtils::ParseXS::CountLines; ExtUtils::ParseXS::CountLines->VERSION($VERSION);
+  require ExtUtils::ParseXS::Utilities; ExtUtils::ParseXS::Utilities->VERSION($VERSION);
+  require ExtUtils::ParseXS::Eval; ExtUtils::ParseXS::Eval->VERSION($VERSION);
 }
-use ExtUtils::ParseXS::Constants $VERSION;
-use ExtUtils::ParseXS::CountLines $VERSION;
-use ExtUtils::ParseXS::Utilities $VERSION;
-use ExtUtils::ParseXS::Eval $VERSION;
 $VERSION = eval $VERSION if $VERSION =~ /_/;
 
 use ExtUtils::ParseXS::Utilities qw(
-- 
2.16.2

@p5pRT
Copy link
Author

p5pRT commented Mar 5, 2018

From @skaji

Typo​:

(False) I think I understand ExtUtils​::ParseXS explicitly require current version of submodules.
(True) I think I understand why ExtUtils​::ParseXS explicitly require current version of submodules.

On Mon, 05 Mar 2018 06​:50​:06 -0800, skaji@​cpan.org wrote​:

Hi James,

Thanks for your reply.
I think I understand ExtUtils​::ParseXS explicitly require current
version of submodules. The point here is that the version check does
not work.

Hi Father,

Tanks for your comment.

I don’t like the patch, because of the maintenance burden it creates
(multiple numbers to update). I wouldn’t mind a patch that calls
->VERSION($VERSION) explicitly in a BEGIN block.

I understand. I added another patch which call require() and
->VERSION() in BEGIN block.

On Sun, 04 Mar 2018 18​:56​:17 -0800, sprout wrote​:

On Sun, 04 Mar 2018 18​:24​:12 -0800, jkeenan wrote​:

On Sun, 04 Mar 2018 07​:10​:18 GMT, skaji@​outlook.com wrote​:

This is a bug report for perl from skaji@​outlook.com,
generated with the help of perlbug 1.40 running under perl
5.26.1.

-----------------------------------------------------------------
[Please describe your issue here]

Currently in ExtUtils​::ParseXS, the version check does not work
because we use variables for VERSION​:

```
our $VERSION;
BEGIN {
$VERSION = '3.38';
}
use ExtUtils​::ParseXS​::Constants $VERSION;
```

We must use literals for VERSION.
A patch for this is attached to this e-mail.

Please see the explanation provided by Steffen Mueller in commit
71a65ad back in 2011​:

#####
ExtUtils​::ParseXS​: Explicitly require current version of submodules

Since there have been certain problems with parts of
ExtUtils​::ParseXS
being shadowed by older installations of the module, this commit
adds
an explicit $VERSION to all submodules and requires them to have
the
same version as the main module. This doesn't actually fix any
problem, but makes them more apparent as early as possible instead
of
failing with obscure compile errors when bad C is generated from
the
original XS.
#####

That explains why version checks are a good idea. It does not
justify
the fact that that commit failed to add any version checks.

This​:

use ExtUtils​::ParseXS​::Constants $VERSION;

is equivalent to​:

BEGIN {
require ExtUtils​::ParseXS​::Constants;
'ExtUtils​::ParseXS​::Constants'->import;
}

And a call to a nonexistent import method is silently ignored.

I don’t like the patch, because of the maintenance burden it creates
(multiple numbers to update). I wouldn’t mind a patch that calls
->VERSION($VERSION) explicitly in a BEGIN block.

@p5pRT
Copy link
Author

p5pRT commented Mar 5, 2018

From @skaji

Hi James,

Thanks for your reply.
I think I understand why ExtUtils​::ParseXS explicitly require current version of submodules.

My point is here that
we must use "literals" instead of "variables" for version check.

For example, the following code UNEXPECTEDLY prints "NEVER REACH HERE!".

```
#!/usr/bin/env perl
use strict;
use warnings;

my $version;
BEGIN { $version = "99999" }
use HTTP​::Tiny $version;

warn "NEVER REACH HERE!\n";
```

________________________________________
From​: James E Keenan via RT <perlbug-followup@​perl.org>
Sent​: Monday, March 5, 2018 11​:24
To​: skaji@​outlook.com
Subject​: [perl #132935] [PATCH] ExtUtils​::ParseXS​: use literals for VERSION in 'use Module VERSION'

On Sun, 04 Mar 2018 07​:10​:18 GMT, skaji@​outlook.com wrote​:

This is a bug report for perl from skaji@​outlook.com,
generated with the help of perlbug 1.40 running under perl 5.26.1.

-----------------------------------------------------------------
[Please describe your issue here]

Currently in ExtUtils​::ParseXS, the version check does not work
because we use variables for VERSION​:

```
our $VERSION;
BEGIN {
$VERSION = '3.38';
}
use ExtUtils​::ParseXS​::Constants $VERSION;
```

We must use literals for VERSION.
A patch for this is attached to this e-mail.

Please see the explanation provided by Steffen Mueller in commit 71a65ad back in 2011​:

#####
ExtUtils​::ParseXS​: Explicitly require current version of submodules

Since there have been certain problems with parts of ExtUtils​::ParseXS being shadowed by older installations of the module, this commit adds an explicit $VERSION to all submodules and requires them to have the same version as the main module. This doesn't actually fix any problem, but makes them more apparent as early as possible instead of failing with obscure compile errors when bad C is generated from the original XS.
#####

Thank you very much.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Mar 5, 2018

From @cpansprout

On Mon, 05 Mar 2018 06​:50​:06 -0800, skaji@​cpan.org wrote​:

Hi James,

Thanks for your reply.
I think I understand ExtUtils​::ParseXS explicitly require current
version of submodules. The point here is that the version check does
not work.

Hi Father,

Tanks for your comment.

I don’t like the patch, because of the maintenance burden it creates
(multiple numbers to update). I wouldn’t mind a patch that calls
->VERSION($VERSION) explicitly in a BEGIN block.

I understand. I added another patch which call require() and
->VERSION() in BEGIN block.

Thank you. Applied as 8a89137.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Mar 5, 2018

@cpansprout - Status changed from 'open' to 'pending release'

@p5pRT
Copy link
Author

p5pRT commented Mar 5, 2018

From @skaji

Thanks!

On Mon, 05 Mar 2018 08​:48​:30 -0800, sprout wrote​:

On Mon, 05 Mar 2018 06​:50​:06 -0800, skaji@​cpan.org wrote​:

Hi James,

Thanks for your reply.
I think I understand ExtUtils​::ParseXS explicitly require current
version of submodules. The point here is that the version check does
not work.

Hi Father,

Tanks for your comment.

I don’t like the patch, because of the maintenance burden it creates
(multiple numbers to update). I wouldn’t mind a patch that calls
->VERSION($VERSION) explicitly in a BEGIN block.

I understand. I added another patch which call require() and
->VERSION() in BEGIN block.

Thank you. Applied as 8a89137.

@p5pRT
Copy link
Author

p5pRT commented Jun 23, 2018

From @khwilliamson

Thank you for filing this report. You have helped make Perl better.

With the release yesterday of Perl 5.28.0, this and 185 other issues have been
resolved.

Perl 5.28.0 may be downloaded via​:
https://metacpan.org/release/XSAWYERX/perl-5.28.0

If you find that the problem persists, feel free to reopen this ticket.

@p5pRT
Copy link
Author

p5pRT commented Jun 23, 2018

@khwilliamson - Status changed from 'pending release' to 'resolved'

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

No branches or pull requests

1 participant