DynaLoader: Pure-perl mod2fname shouldn't use %Config at runtime
authorBrian Fraser <fraserbn@gmail.com>
Sat, 18 Jan 2014 13:03:00 +0000 (10:03 -0300)
committerBrian Fraser <fraserbn@gmail.com>
Sat, 18 Jan 2014 14:01:27 +0000 (11:01 -0300)
This is somewhat obscure.  Previously, mod2fname would've tried
accessing $Config{dlext} each time it was called.  The reason this
can be problematic is that mod2fname can be called during global destruction,
after %Config is freed but before its magic is.  This was causing
Devel::GlobalDestruction's tests to fail on builds with -Dd_libname_unique.

This commit grabs the data we need when DynaLoader.pm is being built in
DynaLoader_pm.PL, so it no longer need to depend on %Config.

ext/DynaLoader/DynaLoader_pm.PL

index 6c2a3e6..5c71aaf 100644 (file)
@@ -85,7 +85,7 @@ package DynaLoader;
 # Tim.Bunce@ig.co.uk, August 1994
 
 BEGIN {
-    $VERSION = '1.23';
+    $VERSION = '1.24';
 }
 
 use Config;
@@ -236,10 +236,10 @@ EOT
 }
 
 if ( $Config::Config{d_libname_unique} ) {
-    print OUT <<'EOT';
+    printf OUT <<'EOT', length($Config::Config{dlext}) + 1;
 sub mod2fname {
     my $parts = shift;
-    my $so_len = length($Config::Config{dlext})+1;
+    my $so_len = %d;
     my $name_max = 255; # No easy way to get this here
     
     my $libname = "PL_" .  join("__", @$parts);