Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
XP is just a number
 
PerlMonks

constant.pm + index() + Pod::Coverage crashes on Perl 5.10

by hma (Monk)
 | Log in | Create a new user | The Monastery Gates | Super Search | 
 | Seekers of Perl Wisdom | Meditations | PerlMonks Discussion | 
 | Obfuscation | Reviews | Cool Uses For Perl | Perl News | Q&A | Tutorials | 
 | Poetry | Recent Threads | Newest Nodes | Donate | What's New | 

on Dec 05, 2008 at 23:58 UTC ( #728434=perlquestion: print w/ replies, xml ) Need Help??
hma has asked for the wisdom of the Perl Monks concerning the following question:

Dear monks,

I released my second module, Biblio::Refbase, to CPAN on Sunday.

I've got now the first CPAN Testers error reports with a quite surprising result. The one of all tests failing is the standard pod-coverage test on some Perl 5.10 environments.

Currently I've got 6 fails (all 5.10) and 42 passes (12 passes on 5.10).(see at CPAN Testers)

I could reproduce the error on Strawberry Perl 5.10 and ActiveState Perl 5.10 on Windows: Perl just crashes when I run t/06-pod-coverage.

I tracked down the location of the crash and the situation when it happens. I use constant in my module and have some index($string, CONSTANT) calls in my code. Pod::Coverage uses Devel::Symdump to walk the symbol tree, which lets Perl crash in the moment it takes action on one of the constants I use as parameter to the index function (my other use of constants makes no problems).

I've prepared a code snippet that simulates the situation I think my module enters.

Here's the code:

use Devel::Symdump; my $x = Mod::idx('some string'); print "x=$x\n"; # works, x=5 my $obj = Devel::Symdump->new('Mod'); # crash on 5.10 package Mod; use constant 'STRING' => 'string'; sub idx { my $s = shift; return index($s, STRING); }

The crash happens in Devel::Symdump (version 2.08, line 55), where this code is executed:

local(*ENTRY) = $val;

If I print $val it reads: GLOB(0x1fa64e4)

Further investigation lead me to constant.pm (1.17, line 106):

if ($symtab && !exists $symtab->{$name}) { # No typeglob yet, so we can use a reference as space- # efficient proxy for a constant subroutine # The check in Perl_ck_rvconst knows that inlinable # constants from cv_const_sv are read only. So we have to: Internals::SvREADONLY($scalar, 1); $symtab->{$name} = \$scalar; mro::method_changed_in($pkg); } else { *$full_name = sub () { $scalar }; }

As far as I can tell this is an optimization in 5.10.

If I change the if-condition (0 && $symtab ...) to force the "else" branch, the crash does not happen.

$val then reads: *Mod::STRING

Lucky me, I found a solution for my module. Of course I didn't want to remove pod-coverage from the test suite (and I didn't want to switch to Readonly or plain variables or to use a regex instead of index). If I force the constant into scalar context, it works, too:

index($s, scalar STRING)

$val then reads (with unmodified constant.pm): SCALAR(0x1fa65ec)

I replaced the constant in index() with a simple function showing the state of wantarray(). I think the context is always scalar, so using scalar() should make no difference. But it does in the situation above!?

At this point I came to the edge of my knowledge and decided to head for the wisdom of the monks (I've been registered here for more than a year but never posted something until now. But I've read many, many marvellous posts. Thanks, monks!)

I'm very interested in some explanation or direction to the source of some explanation.

And then, if the problem I encountered is a bug (I think so), I would like advice whom to tell.

My assumptions (in descending order): It's a bug in

  • Perl 5.10 (because of the crash)
  • constant.pm (because of the magic optimization)
  • Devel::Symdump (perhaps it should check $val?)

Thanks in advance,
Henning Manske

Comment on constant.pm + index() + Pod::Coverage crashes on Perl 5.10
Select or Download Code

Login:
Password
remember me
What's my password?
Create A New User

Node Status?
node history
Node Type: perlquestion [id://728434]
Approved by friedo
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (25)
BrowserUk
GrandFather
jdporter
wfsp
johngg
atcroft
mr_mischief
kennethk
herveus
MidLifeXis
Marshall
rowdog
psini
SFLEX
jkva
ssandv
DStaal
wwe
AndyZaft
Neighbour
dxxd116
DarthWavy
graghave
ldbpm
im2
As of 2010-09-02 15:08 GMT
Sections?
Seekers of Perl Wisdom
Cool Uses for Perl
Meditations
PerlMonks Discussion
Categorized Q&A
Tutorials
Obfuscated Code
Perl Poetry
Perl News
See About the sections of PerlMonks
Information?
PerlMonks FAQ
Guide to the Monastery
What's New at PerlMonks
Voting/Experience System
Tutorials
Reviews
Library
Perl FAQs
Other Info Sources
Find Nodes?
Nodes You Wrote
Super Search
List Nodes By Users
Newest Nodes
Recently Active Threads
Selected Best Nodes
Best Nodes
Worst Nodes
Saints in our Book
Leftovers?
The St. Larry Wall Shrine
Offering Plate
Awards
Craft
Snippets Section
Code Catacombs
Quests
Editor Requests
Buy PerlMonks Gear
PerlMonks Merchandise
Planet Perl
Perlsphere
Use Perl
Perl.com
Perl 5 Wiki
Perl Jobs
Perl Mongers
Perl Directory
Perl documentation
CPAN
Random Node
Voting Booth?

My favourite poll on PerlMonks is ...

Your first Perl Book - the first one ever
Average number of caffeinated beverages per work day - the poll with the highest participation
My Thoughts on the New Voting/Experience System - the poll with the fewest votes cast
When I grow up, I want to be: - one of the polls with the fewest options
Perl 6 will primarily be: - the first one on Perl6
When I see a poll - one of the many polls about polls
this poll ;-)
yet to come
none - I hate polls. Bah.
some other

Results (49 votes), past polls