Skip Menu |
 

This queue is for tickets about the Regexp-Grammars CPAN distribution.

Report information
The Basics
Id: 68600
Status: open
Priority: 0/
Queue: Regexp-Grammars

People
Owner: Nobody in particular
Requestors: kolibrie [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



From kolibrie [...] graystudios.org Wed Jun 1 13: 36:02 2011
MIME-Version: 1.0
X-Spam-Status: No, score=-5.232 tagged_above=-99.9 required=10 tests=[BAYES_00=-1.9, DNS_FROM_RFC_BOGUSMX=1.668, RCVD_IN_DNSWL_HI=-5] autolearn=ham
Content-Disposition: inline
X-Spam-Flag: NO
X-Virus-Checked: Checked by ClamAV on 16.mx.develooper.com
Message-ID: <20110601173526.GA10099 [...] vs1.graystudios.org>
Content-Type: multipart/mixed; boundary="Boundary_(ID_H7TvD0fXebpC4l7Yw+cKUg)"
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
X-Spam-Score: -5.232
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id CC5F32402C6 for <cpan-bug+regexp-grammars [...] hipster.bestpractical.com>; Wed, 1 Jun 2011 13:36:01 -0400 (EDT)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DauIOTjb9C5U for <cpan-bug+regexp-grammars [...] hipster.bestpractical.com>; Wed, 1 Jun 2011 13:36:00 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id 9D10E24020B for <bug-regexp-grammars [...] rt.cpan.org>; Wed, 1 Jun 2011 13:35:59 -0400 (EDT)
Received: (qmail 29642 invoked by uid 103); 1 Jun 2011 17:35:58 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 1 Jun 2011 17:35:58 -0000
Received: from vms173017pub.verizon.net (HELO vms173017pub.verizon.net) (206.46.173.17) by 16.mx.develooper.com (qpsmtpd/0.80/v0.80-19-gf52d165) with ESMTP; Wed, 01 Jun 2011 10:35:56 -0700
Received: from vs1.graystudios.org ([unknown] [71.178.237.99]) by vms173017.mailsrvcs.net (Sun Java(tm) System Messaging Server 7u2-7.02 32bit (built Apr 16 2009)) with ESMTPA id <0LM400MNDGVN9GX3 [...] vms173017.mailsrvcs.net> for bug-regexp-grammars [...] rt.cpan.org; Wed, 01 Jun 2011 12:35:53 -0500 (CDT)
Received: from kolibrie by vs1.graystudios.org with local (Exim 4.69) (envelope-from <kolibrie [...] graystudios.org>) id 1QRpKN-0003eD-KG for bug-regexp-grammars [...] rt.cpan.org; Wed, 01 Jun 2011 13:35:31 -0400
Delivered-To: cpan-bug+regexp-grammars [...] hipster.bestpractical.com
User-Agent: Mutt/1.5.18 (2008-05-17)
Subject: objrule does not work with Moose nor AUTOLOAD
Return-Path: <kolibrie [...] graystudios.org>
X-RT-Mail-Extension: regexp-grammars
X-Original-To: cpan-bug+regexp-grammars [...] hipster.bestpractical.com
X-Spam-Check-BY: 16.mx.develooper.com
Date: Wed, 01 Jun 2011 13:35:26 -0400
X-Spam-Level:
To: bug-regexp-grammars [...] rt.cpan.org
Content-Transfer-Encoding: 8BIT
From: Nathan Gray <kolibrie [...] cpan.org>
Content-Length: 0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8BIT
X-RT-Original-Encoding: utf-8
Content-Length: 2207
Download (untitled) / with headers
text/plain 2.1k
I am not able to use Moose objects for objrule results. I get strange results when I use classes that use AUTOLOAD. The module works correctly when I use the new method taken from data_structure.t in the Regexp::Grammars distribution, or if I use Class::Accessor objects. I am attaching several test scripts: new.t - based on data_structure.t in the distribution 1..2 ok 1 - Matched ok 2 - Returned correct data structure moose.t - use a Moose object 1..2 Segmentation fault class_accessor.t - use a Class::Accessor object 1..2 ok 1 - Matched ok 2 - Returned correct data structure new_init.t - use a hand-coded object that populates each attribute via an init routine 1..2 ok 1 - Matched ok 2 - Returned correct data structure new_init_autoload.t - uses AUTOLOAD for all accessor methods 1..2 Segmentation fault new_init_limited_autoload.t - uses AUTOLOAD only for accessors that have been listed as allowed 1..2 ok 1 - Matched not ok 2 - Returned correct data structure # Failed test 'Returned correct data structure' # at t/new_init_limited_autoload.t line 75. # Structures begin differing at: # $got->{} = '� �� �� � ' # $expected->{} = '<a href="/yn2011/user/1613">Nathan Gray # (&lrm;kolibrie&lrm;)' # Looks like you failed 1 test of 2. new_init_limited_autoload_warn.t - identical, but has a warn statement 1..2 running AUTOLOAD as 'name' with param 'Nathan Gray' running AUTOLOAD as 'id' with param '1613' running AUTOLOAD as 'alias' with param 'kolibrie' Segmentation fault I am mostly interested in getting Moose to work with Regexp::Grammars. I wrote the other test scripts to try to debug what is going on. When I run moose.t through the Perl debugger, I'm not able to see where the error is, mostly it is just a bunch of reeval messages: DB<2> s main::((reeval 148)[t/moose.t:34]:3): 3: DB<2> s main::((reeval 149)[t/moose.t:34]:2): 2: DB<2> s Signal SEGV at (reeval 149)[t/moose.t:34] line 2 Aborted Tested with: Perl v5.10.1 Regexp::Grammars 1.012 Moose 2.0007 Class::Accessor 0.34 -kolibrie
content-type: application/x-perl; name="new.t"
content-disposition: attachment; filename="new.t"
Content-Transfer-Encoding: quoted-printable
Content-Length: 1607
Download new.t
text/x-perl 1.5k

Message body is not shown because sender requested not to inline it.

content-type: application/x-perl; name="moose.t"
content-disposition: attachment; filename="moose.t"
Content-Transfer-Encoding: quoted-printable
Content-Length: 1601
Download moose.t
text/x-perl 1.5k

Message body is not shown because sender requested not to inline it.

content-type: application/x-perl; name="class_accessor.t"
content-disposition: attachment; filename="class_accessor.t"
Content-Transfer-Encoding: quoted-printable
Content-Length: 1526
Download class_accessor.t
text/x-perl 1.4k

Message body is not shown because sender requested not to inline it.

content-type: application/x-perl; name="new_init.t"
content-disposition: attachment; filename="new_init.t"
Content-Transfer-Encoding: quoted-printable
Content-Length: 2293
Download new_init.t
text/x-perl 2.2k

Message body is not shown because sender requested not to inline it.

content-type: application/x-perl; name="new_init_autoload.t"
content-disposition: attachment; filename="new_init_autoload.t"
Content-Transfer-Encoding: quoted-printable
Content-Length: 2168
Download new_init_autoload.t
text/x-perl 2.1k

Message body is not shown because sender requested not to inline it.

content-type: application/x-perl; name="new_init_limited_autoload.t"
content-disposition: attachment; filename="new_init_limited_autoload.t"
Content-Transfer-Encoding: quoted-printable
Content-Length: 2276

Message body is not shown because sender requested not to inline it.

content-type: application/x-perl; name="new_init_limited_autoload_warn.t"
content-disposition: attachment; filename="new_init_limited_autoload_warn.t"
Content-Transfer-Encoding: quoted-printable
Content-Length: 2275

Message body is not shown because sender requested not to inline it.

From thoughtstream [...] gmail.com Wed Jun 1 22: 08:25 2011
MIME-Version: 1.0
X-Spam-Status: No, score=-6.81 tagged_above=-99.9 required=10 tests=[AWL=-0.701, BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_HI=-5, RFC_ABUSE_POST=0.001, SPF_NEUTRAL=0.779, T_TO_NO_BRKTS_FREEMAIL=0.01] autolearn=ham
In-Reply-To: <rt-3.8.HEAD-18806-1306949763-1808.68600-4-0 [...] rt.cpan.org>
X-Spam-Flag: NO
References: <RT-Ticket-68600 [...] rt.cpan.org> <20110601173526.GA10099 [...] vs1.graystudios.org> <rt-3.8.HEAD-18806-1306949763-1808.68600-4-0 [...] rt.cpan.org>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
Message-ID: <BANLkTikHqZzrtX753DcyS0X4z5gO357HhA [...] mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
X-RT-Original-Encoding: utf-8
X-Spam-Score: -6.81
Authentication-Results: hipster.bestpractical.com (amavisd-new); dkim=pass header.i= [...] gmail.com
Authentication-Results: hipster.bestpractical.com (amavisd-new); domainkeys=pass header.sender=thoughtstream [...] gmail.com
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id C8AE12402D1 for <cpan-bug+Regexp-Grammars [...] hipster.bestpractical.com>; Wed, 1 Jun 2011 22:08:25 -0400 (EDT)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id R1IxYiZau5c5 for <cpan-bug+Regexp-Grammars [...] hipster.bestpractical.com>; Wed, 1 Jun 2011 22:08:24 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id 14A7F24022A for <bug-Regexp-Grammars [...] rt.cpan.org>; Wed, 1 Jun 2011 22:08:23 -0400 (EDT)
Received: (qmail 759 invoked by uid 103); 2 Jun 2011 02:08:23 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 2 Jun 2011 02:08:23 -0000
Received: from mail-bw0-f50.google.com (HELO mail-bw0-f50.google.com) (209.85.214.50) by 16.mx.develooper.com (qpsmtpd/0.80/v0.80-19-gf52d165) with ESMTP; Wed, 01 Jun 2011 19:08:20 -0700
Received: by bwz2 with SMTP id 2so601253bwz.9 for <bug-Regexp-Grammars [...] rt.cpan.org>; Wed, 01 Jun 2011 19:08:17 -0700 (PDT)
Received: by 10.204.137.68 with SMTP id v4mr167587bkt.115.1306980497151; Wed, 01 Jun 2011 19:08:17 -0700 (PDT)
Received: by 10.204.154.84 with HTTP; Wed, 1 Jun 2011 19:07:36 -0700 (PDT)
Delivered-To: cpan-bug+Regexp-Grammars [...] hipster.bestpractical.com
Subject: Re: [rt.cpan.org #68600] objrule does not work with Moose nor AUTOLOAD
Domainkey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:content-type :content-transfer-encoding; b=sAoIfU32WMlXUbkSgKfAn9VeGmm0tHtkp39Qp+rK521DRopiTfE5wWY2yPSyA4Q7VK jOKmfVPRE0rgrGXQBwlZQSWx2Aqv9EA5i1mIxuWYM5oP/6vVCA5JGE7OIMXLmu8kRCMk I/dk7A/OpptUuGjLTKLMJWdkChAkRL4j8+9UM=
Return-Path: <thoughtstream [...] gmail.com>
Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:from :date:x-google-sender-auth:message-id:subject:to:content-type :content-transfer-encoding; bh=bug7Yd7UZxnzFIBc5WOsc/X5Ja3+S1dyblXb16nUu1c=; b=ira/u3d2qe4Cta+xGpBr9oovRHMx0v85E89efldo8tinp5el/+1UBSW8GgMRAF5KYw /yS5Kjrj+6Leo+0+W63FXwBIiXftEEA5qK8AJlcpd/MepGayV2JAO7u0HRq4lepUEDB0 PWV1Nox5SS1GKdU/BVolyF+echAf07TSvaxU8=
X-Spam-Check-BY: 16.mx.develooper.com
X-Original-To: cpan-bug+Regexp-Grammars [...] hipster.bestpractical.com
X-RT-Mail-Extension: regexp-grammars
X-Google-Sender-Auth: kK3lFUaGE2AFOVIVJ_jbbexpn6o
Sender: thoughtstream [...] gmail.com
Date: Thu, 2 Jun 2011 12:07:36 +1000
X-Spam-Level:
To: bug-Regexp-Grammars [...] rt.cpan.org
Content-Transfer-Encoding: quoted-printable
From: Damian Conway <damian [...] conway.org>
RT-Message-ID: <rt-3.8.HEAD-18806-1306980506-103.68600-0-0 [...] rt.cpan.org>
Content-Length: 3309
Download (untitled) / with headers
text/plain 3.2k
Hi Nathan, Thanks for the excellent bug-report, and especially for the numerous .t files, all of which have now been added to the distribution. Show quoted text
> I am not able to use Moose objects for objrule results.  I get > strange results when I use classes that use AUTOLOAD.
Both the problems you experienced stem from a single cause: the Perl regex engine is not re-entrant (at least, not prior to 5.14.0). The Moose problem you encountered is caused by the fact that some 'isa' type constraints are implemented by testing against regexes. In this case the 'isa' => 'INT' is the culprit. Changing it to something that isn't tested by regex (e.g. to: 'isa' => 'NUM') solves the problem. In the case of the various AUTOLOAD examples, the problem was that your AUTOLOAD() methods included a substitution: $var =~ s/.*://; Changing that line to the non-regex-based equivalent: my $last_colon_pos = rindex($var, ':'); substr $var, 0, $last_colon_pos+1, q{}; removes the problem for all the examples. The bottom line is that this is a perl issue, not a Regexp::Grammars issue. To solve it, you either have to avoid any class that uses regexes in its constructor, or you have to upgrade to 5.14.0. I have now added a new section to the documentation pointing out this inherent limitation of older Perl's: =head4 An important caveat regarding OO rules Prior to Perl 5.14.0, Perl's regex engine was not fully re-entrant. This means that in older versions of Perl, it is not possible to re-invoke the regex engine when already inside the regex engine. This means that you need to be careful that the C<new()> constructors that are called by your object-rules do not themselves use regexes in any way, unless you're running under Perl 5.14 or later (in which case you can ignore what follows). The two ways this is most likely to happen are: =over =item 1. If you're using a class built on Moose, where one or more of the C<has> uses a type constraint (such as C<'Int'>) that is implemented via regex matching. For example: has 'id' => (is => 'rw', isa => 'Int'); The workaround (for pre-5.14 Perls) is to replace the type constraint with one that doesn't use a regex. For example: has 'id' => (is => 'rw', isa => 'Num'); Alternatively, you could define your own type constraint that avoids regexes: use Moose::Util::TypeConstraints; subtype 'Non::Regex::Int', as 'Num', where { int($_) == $_ }; no Moose::Util::TypeConstraints; # and later... has 'id' => (is => 'rw', isa => 'Non::Regex::Int'); =item 2. If your class uses an C<AUTOLOAD()> method to implement its constructor and that method uses the typical: $AUTOLOAD =~ s/.*://; technique. The workaround here is to achieve the same effect without a regex. For example: my $last_colon_pos = rindex($AUTOLOAD, ':'); substr $AUTOLOAD, 0, $last_colon_pos+1, q{}; =back Note that this caveat against using nested regexes also applies to any code blocks executed inside a rule or token (whether or not those rules or tokens are object-oriented). Thanks again for bringing this to my attention, Nathan. Damian
From kolibrie [...] graystudios.org Thu Jun 2 05: 21:55 2011
MIME-Version: 1.0
X-Spam-Status: No, score=-5.232 tagged_above=-99.9 required=10 tests=[BAYES_00=-1.9, DNS_FROM_RFC_BOGUSMX=1.668, RCVD_IN_DNSWL_HI=-5] autolearn=ham
In-Reply-To: <rt-3.8.HEAD-18806-1306980506-1035.68600-6-0 [...] rt.cpan.org>
Content-Disposition: inline
X-Spam-Flag: NO
References: <RT-Ticket-68600 [...] rt.cpan.org> <20110601173526.GA10099 [...] vs1.graystudios.org> <rt-3.8.HEAD-18806-1306949763-1808.68600-4-0 [...] rt.cpan.org> <BANLkTikHqZzrtX753DcyS0X4z5gO357HhA [...] mail.gmail.com> <rt-3.8.HEAD-18806-1306980506-1035.68600-6-0 [...] rt.cpan.org>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
Message-ID: <20110602092115.GA18984 [...] vs1.graystudios.org>
Content-Type: text/plain; charset="utf-8"
X-RT-Original-Encoding: utf-8
X-Spam-Score: -5.232
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id 961C1240248 for <cpan-bug+Regexp-Grammars [...] hipster.bestpractical.com>; Thu, 2 Jun 2011 05:21:55 -0400 (EDT)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id e5REoT-1u+RQ for <cpan-bug+Regexp-Grammars [...] hipster.bestpractical.com>; Thu, 2 Jun 2011 05:21:54 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id BDCD924022A for <bug-Regexp-Grammars [...] rt.cpan.org>; Thu, 2 Jun 2011 05:21:53 -0400 (EDT)
Received: (qmail 28169 invoked by uid 103); 2 Jun 2011 09:21:53 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 2 Jun 2011 09:21:53 -0000
Received: from vms173007pub.verizon.net (HELO vms173007pub.verizon.net) (206.46.173.7) by 16.mx.develooper.com (qpsmtpd/0.80/v0.80-19-gf52d165) with ESMTP; Thu, 02 Jun 2011 02:21:50 -0700
Received: from vs1.graystudios.org ([unknown] [71.178.237.99]) by vms173007.mailsrvcs.net (Sun Java(tm) System Messaging Server 7u2-7.02 32bit (built Apr 16 2009)) with ESMTPA id <0LM50094IOO0HM00 [...] vms173007.mailsrvcs.net> for bug-Regexp-Grammars [...] rt.cpan.org; Thu, 02 Jun 2011 04:21:42 -0500 (CDT)
Received: from kolibrie by vs1.graystudios.org with local (Exim 4.69) (envelope-from <kolibrie [...] graystudios.org>) id 1QS45h-0004xh-Fm for bug-Regexp-Grammars [...] rt.cpan.org; Thu, 02 Jun 2011 05:21:21 -0400
Delivered-To: cpan-bug+Regexp-Grammars [...] hipster.bestpractical.com
Subject: Re: [rt.cpan.org #68600] objrule does not work with Moose nor AUTOLOAD
User-Agent: Mutt/1.5.18 (2008-05-17)
Return-Path: <kolibrie [...] graystudios.org>
X-Spam-Check-BY: 16.mx.develooper.com
X-Original-To: cpan-bug+Regexp-Grammars [...] hipster.bestpractical.com
X-RT-Mail-Extension: regexp-grammars
Date: Thu, 02 Jun 2011 05:21:16 -0400
X-Spam-Level:
To: "damian [...] conway.org via RT" <bug-Regexp-Grammars [...] rt.cpan.org>
From: Nathan Gray <kolibrie [...] cpan.org>
RT-Message-ID: <rt-3.8.HEAD-18805-1307006516-298.68600-0-0 [...] rt.cpan.org>
Content-Length: 294
Download (untitled) / with headers
text/plain 294b
On Wed, Jun 01, 2011 at 10:08:27PM -0400, damian@conway.org via RT wrote: Show quoted text
> Thanks for the excellent bug-report, and especially for the numerous .t files, > all of which have now been added to the distribution.
Thank you for the very clear new documentation, and swift turnaround. -kolibrie


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.