Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I tried using Regexp::Grammars together with MooseX::Declare, and the result was… a segfault. My code is:

#!/usr/bin/perl use MooseX::Declare; my $gr = do { use Regexp::Grammars; qr { <Foo> <objrule: Foo> foo }x; }; class Foo { method BUILD { use Data::Dumper; print 'AH ', Dumper \@_; } } my $m = 'foo' =~ $gr or die 'no match';

The output of this program is:

AH $VAR1 = [ bless( {}, 'Foo' ), { '@' => {}, '!' => '-1' } ]; Segmentation fault

These strange hash keys ("@" and "!") seem to be some internal values of Regexp::Grammars. I see nothing about them in the documentation, so I'd say their exposure is a bug. However this does not seem to have anything to do with the segfault: The grammar calls the Foo constructor like in the following, but it won't segfault if I do so manually:

Foo->new( { '@' => {}, '!' => '-1' } );

Also, the segmentation fault disappears if I do either of:

  • remove the BUILD method
  • write the class direcly in Moose (without MooseX::Declare)

I should probably report a bug somewhere. However I am unsure where it should be reported. Regexp::Grammar itself does not seem to use any XS or lowlevel stuff, so it is probably not the problem. However, it uses many funny features of the new regexp engine. MooseX::Declare on the other hand uses a whole bunch of modules with a lot of magic in them. Maybe you can help me pinpoint the origin of this bug.

I use perl v5.10.1, MooseX::Declare 0.34, Regexp::Grammars 1.012, all current Debian wheezy versions.


In reply to Segfault with MooseX::Declare and Regexp::Grammars by betterworld

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2024-04-19 17:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found