Unbreak Concise glob output
authorFather Chrysostomos <sprout@cpan.org>
Sun, 25 Aug 2013 14:07:37 +0000 (07:07 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 25 Aug 2013 19:12:36 +0000 (12:12 -0700)
$ ./perl -MO=Concise -Ilib -le '; print <\n>'
8  <@> leave[1 ref] vKP/REFC ->(end)
1     <0> enter ->2
2     <;> nextstate(main 23 -e:1) v:{ ->3
7     <@> print vK ->8
3        <0> pushmark s ->4
6        <@> glob[t2] lK/1 ->7
-           <0> ex-pushmark s ->4
4           <$> const[PV "\n"] s ->5
Can't locate object method "NAME" via package "B::SPECIAL" at lib/B/Concise.pm line 707.
CHECK failed--call queue aborted.

e88567f2acf38fe5ed90a88569b808e82cd3eca1 is the first bad commit
commit e88567f2acf38fe5ed90a88569b808e82cd3eca1
Author: Father Chrysostomos <sprout@cpan.org>
Date:   Sun Nov 4 20:18:51 2012 -0800

    Stop the glob operator from leaking GVs

    It was adding GVs to the symbol table (via newGVgen), so they
    would never be freed, even after the op was freed, unless done so
    explicitly.

    There is no reason for these GVs to be exposed.

That means $gv->STASH returns a B::SPECIAL.  B::Concise was not pre-
pared to handle that.

ext/B/B/Concise.pm
ext/B/t/concise.t

index 2007226..b074906 100644 (file)
@@ -704,7 +704,14 @@ sub concise_sv {
     $hr->{svaddr} = sprintf("%#x", $$sv);
     if ($hr->{svclass} eq "GV" && $sv->isGV_with_GP()) {
        my $gv = $sv;
-       my $stash = $gv->STASH->NAME; if ($stash eq "main") {
+       my $stash = $gv->STASH;
+       if (class($stash) eq "SPECIAL") {
+           $stash = "<none>";
+       }
+       else {
+           $stash = $stash->NAME;
+       }
+       if ($stash eq "main") {
            $stash = "";
        } else {
            $stash = $stash . "::";
index b945e56..948d836 100644 (file)
@@ -10,7 +10,7 @@ BEGIN {
     require 'test.pl';         # we use runperl from 'test.pl', so can't use Test::More
 }
 
-plan tests => 160;
+plan tests => 161;
 
 require_ok("B::Concise");
 
@@ -459,4 +459,11 @@ $out =
  );
 unlike $out, 'main::foo', '-nobanner';
 
+# glob
+$out =
+ runperl(
+  switches => ["-MO=Concise"], prog=>'<.>', stderr => 1
+ );
+like $out, '\*<none>::', '<.>';
+
 __END__