From 8316a7e5fe811053d160adb18b0f473d2f070a43 Mon Sep 17 00:00:00 2001 From: Zefram Date: Thu, 20 Jul 2017 07:20:52 +0100 Subject: [PATCH] fix PathTools dynamic linking for Perl 5.6 On Perl 5.6, PathTools's use of SvPV_nomg() is satisfied by a definition in ppport.h. That definition calls out to the function sv_2pv_flags(), which is also not defined by the 5.6. ppport.h can define the function, but doesn't unless requested to. Cwd.xs wasn't requesting it, resulting in Cwd.so having a reference to a non-existent function of a decorated version of that name. Fix this by making Cwd.xs request that function. Some of the existing test cases already exercise the call out to sv_2pv_flags(), but in non-obvious ways. Add a more direct test, requesting canonisation of a number. However, the use of PERL_DL_NONLAZY for running the test suite hides the problem. The XS loading for PathTools is optional, so with PERL_DL_NONLAZY making the loading fail due to the unresolvable symbol, PathTools just falls back to its pure Perl backup implementation, and passes all the tests. The problem only really manifests when PERL_DL_NONLAZY is unset, i.e., in real use: the XS loading succeeds, so PathTools will rely on the XS, but then the code fails when called. This issue remains, lurking to bite if PathTools develops another dynamic linking problem in the future. --- dist/PathTools/Changes | 1 + dist/PathTools/Cwd.xs | 1 + dist/PathTools/t/Spec.t | 1 + 3 files changed, 3 insertions(+) diff --git a/dist/PathTools/Changes b/dist/PathTools/Changes index c3c53ed..b145794 100644 --- a/dist/PathTools/Changes +++ b/dist/PathTools/Changes @@ -3,6 +3,7 @@ Revision history for Perl distribution PathTools. 3.68 - avoid warning from pre-5.8 code for detecting tainted values - make taint.t detect that a pre-5.8 Perl supports tainting +- avoid a dynamic linking problem on Perl 5.6 3.67 - Mon Feb 27 09:33:04 EST 2017 - Add security usage note to File::Spec::no_upwards diff --git a/dist/PathTools/Cwd.xs b/dist/PathTools/Cwd.xs index c6c600b..9f5f7ba 100644 --- a/dist/PathTools/Cwd.xs +++ b/dist/PathTools/Cwd.xs @@ -7,6 +7,7 @@ #include "EXTERN.h" #include "perl.h" #include "XSUB.h" +#define NEED_sv_2pv_flags #define NEED_my_strlcpy #define NEED_my_strlcat #include "ppport.h" diff --git a/dist/PathTools/t/Spec.t b/dist/PathTools/t/Spec.t index 0255bdb..d4fb69a 100644 --- a/dist/PathTools/t/Spec.t +++ b/dist/PathTools/t/Spec.t @@ -139,6 +139,7 @@ my @tests = ( ($] >= 5.008 ? ( [ "Unix->canonpath(do { my \$x = '///a'.chr(0xaf); use utf8 (); utf8::upgrade(\$x); \$x })", '/a'.chr(0xaf) ], ) : ()), +[ "Unix->canonpath(1)", '1' ], [ "Unix->abs2rel('/t1/t2/t3','/t1/t2/t3')", '.' ], [ "Unix->abs2rel('/t1/t2/t4','/t1/t2/t3')", '../t4' ], -- 1.8.3.1