Skip to content

Commit ed57bf8

Browse files
author
Father Chrysostomos
committed
Stop DynaLoader.t from unload File::Glob
File::Glob now sets PL_opfreehook. That means that if we unload it we will leave PL_opfreehook pointing to an invalid address, resulting in a crash when ops are freed. I didn’t catch this because the tests are skipped on darwin. They don’t actually need to be, at least under recent versions, so I modi- fied the skip code.
1 parent 49bb71a commit ed57bf8

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

ext/DynaLoader/t/DynaLoader.t

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ plan tests => 22 + keys(%modules) * 3;
3232
# Try to load the module
3333
use_ok( 'DynaLoader' );
3434

35+
# Some tests need to be skipped on old Darwin versions.
36+
# Commit ce12ed1954 added the skip originally, without specifying which
37+
# darwin version needed it. I know OS X 10.6 (Snow Leopard; darwin 10)
38+
# supports it, so skip anything before that.
39+
my $old_darwin = $^O eq 'darwin' && ($Config{osvers} =~ /^(\d+)/)[0] < 10;
3540

3641
# Check functions
3742
can_ok( 'DynaLoader' => 'bootstrap' ); # defined in Perl section
@@ -43,7 +48,7 @@ if ($Config{usedl}) {
4348
can_ok( 'DynaLoader' => 'dl_load_file' ); # defined in XS section
4449
can_ok( 'DynaLoader' => 'dl_undef_symbols' ); # defined in XS section
4550
SKIP: {
46-
skip "unloading unsupported on $^O", 1 if ($^O eq 'VMS' || $^O eq 'darwin');
51+
skip "unloading unsupported on $^O", 1 if ($old_darwin || $^O eq 'VMS');
4752
can_ok( 'DynaLoader' => 'dl_unload_file' ); # defined in XS section
4853
}
4954
} else {
@@ -137,8 +142,9 @@ is( scalar @DynaLoader::dl_modules, scalar keys %modules, "checking number of it
137142
my @loaded_modules = @DynaLoader::dl_modules;
138143
for my $libref (reverse @DynaLoader::dl_librefs) {
139144
SKIP: {
140-
skip "unloading unsupported on $^O", 2 if ($^O eq 'VMS' || $^O eq 'darwin');
145+
skip "unloading unsupported on $^O", 2 if ($old_darwin || $^O eq 'VMS');
141146
my $module = pop @loaded_modules;
147+
skip "File::Glob sets PL_opfreehook", 2 if $module eq 'File::Glob';
142148
my $r = eval { DynaLoader::dl_unload_file($libref) };
143149
is( $@, '', "calling dl_unload_file() for $module" );
144150
is( $r, 1, " - unload was successful" );

0 commit comments

Comments
 (0)