Skip to content

Commit

Permalink
Merge pull request #24 in BC/perl-compiler from internals-v to bc528
Browse files Browse the repository at this point in the history
* commit 'a7b3b1b948af969b5446500f73f7b11187d69f72':
  Clear Internals::V patches list to avoid them as COWPVs
  • Loading branch information
bdraco committed Aug 25, 2019
2 parents 224474c + a7b3b1b commit 49a39ef
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/B/C_heavy.pl
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,19 @@ sub start_heavy {
}
);

{
no warnings 'redefine';
# do not store the patches
my ($bincompat, $non_bincompat, $date, @patches) = Internals::V();
# Config_heavy and other could require these internal informations
# use an eval to clear the references and convert the PVs to constant
# examples:
# bincompat: HAS_TIMES PERLIO_LAYERS USE_64_BIT_INT USE_LARGE_FILES USE_LOCALE_COLLATE USE_LOCALE_NUMERIC USE_LOCALE_TIME USE_PERLIO
# non_bincompat: PERL_COPY_ON_WRITE PERL_DISABLE_PMC PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP PERL_OP_PARENT PERL_PRESERVE_IVUV PERL_USE_DEVEL USE_LOCALE USE_LOCALE_CTYPE USE_PERL_ATOF
# date: Compiled at Feb 15 2019 18:58:02
*Internals::V = eval qq[sub { return ( "$bincompat", "$non_bincompat", "$date" ) }];
}

B::C::Debug::setup_debug( $settings->{'debug_options'}, $settings->{'enable_verbose'}, $settings->{'enable_debug'} );

die q[Class::XSAccessor::Array is not supported] if $INC{'Class/XSAccessor/Array.pm'};
Expand Down
1 change: 1 addition & 0 deletions t/testsuite/C-COMPILED/extra/internals-v.t
35 changes: 35 additions & 0 deletions t/testsuite/t/extra/internals-v.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!perl

BEGIN {
chdir 't' if -d 't';
require './test.pl';
}


plan tests => 5;

my @patches = (
q["cPanel - disable man installs"],
q["cPanel - cPanel INC PATH"],
q["cPanel - COW Static support"],
q["cPanel - Disable xs handshake"],
);

if ( $0 =~ m{\.bin$} ) {
my $cfile = $0;
$cfile =~ s{bin$}{c};

ok -e $cfile, "cfile exists $cfile";

foreach my $patch ( @patches ) {
my $matches = int qx{egrep -c '#define COWPV.*$patch' $cfile};

print qq[# grep $patch matches $matches\n];
is $matches, 0, "patches name is not leak in the cfile [COWPV]";
}
}
else {
my $tests = 1 + scalar @patches;
ok( 1, "-- skipped not compiled" ) for 1 .. $tests;
}

0 comments on commit 49a39ef

Please sign in to comment.