Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Comment on

( #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

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

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

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

    How do I use this? | Other CB clients
    Other Users?
    Others lurking in the Monastery: (5)
    As of 2018-11-16 05:24 GMT
    Find Nodes?
      Voting Booth?
      My code is most likely broken because:

      Results (193 votes). Check out past polls.

      • (Sep 10, 2018 at 22:53 UTC) Welcome new users!