Skip Menu |

This queue is for tickets about the Parse-RecDescent CPAN distribution.

Report information
The Basics
Id: 52613
Status: resolved
Priority: 0/
Queue: Parse-RecDescent

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

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



Subject: format are wonky with Perl 5.10
Under perl 5.10: This is perl, v5.10.0 built for i486-linux-gnu-thread-multi installed normally via the Ubuntu packages, the P::RD trace, warn, and error outputs produce blank strings. Only the format markers show up but not the actual data. The attached patch brute-forces the issue by reapplying the formats every time trace, warn, or error are needed. I don't know where the formats are dropped, unfortunately. I tried to trace the problem but didn't find an obvious spot. The patch resolves it for me, for now. This happens with any of the demo/*.pl script in the distribution, so it's not a problem with my particular scripts. Thanks Ted
Subject: PRD-format.patch
--- /usr/local/share/perl/5.10.0/Parse/RecDescent.pm 2003-04-09 03:29:37.000000000 -0500 +++ Parse/RecDescent.pm 2009-12-09 10:20:26.000000000 -0600 @@ -2845,12 +2845,6 @@ my $errorprefix; open (ERROR, ">&STDERR"); -format ERROR = -@>>>>>>>>>>>>>>>>>>>>: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -$errorprefix, $errortext -~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - $errortext -. select ERROR; $| = 1; @@ -2863,27 +2857,39 @@ use vars '$tracelevel'; open (TRACE, ">&STDERR"); -format TRACE = + +select TRACE; +$| = 1; + +open (TRACECONTEXT, ">&STDERR"); + +select TRACECONTEXT; +$| = 1; + +apply_formats(); + +sub apply_formats +{ + format ERROR = +@>>>>>>>>>>>>>>>>>>>>: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +$errorprefix, $errortext +~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + $errortext +. + format TRACE = @>|@|||||||||@^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<| $tracelevel, $tracerulename, '|', $tracemsg | ~~ |^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<| $tracemsg . -select TRACE; -$| = 1; - -open (TRACECONTEXT, ">&STDERR"); -format TRACECONTEXT = + format TRACECONTEXT = @>|@|||||||||@ |^<<<<<<<<<<<<<<<<<<<<<<<<<<< $tracelevel, $tracerulename, '|', $tracecontext | ~~ | |^<<<<<<<<<<<<<<<<<<<<<<<<<<< $tracecontext . - - -select TRACECONTEXT; -$| = 1; +} select STDOUT; @@ -2897,6 +2903,7 @@ sub _error($;$) { +apply_formats(); $ERRORS++; return 0 if ! _verbosity("ERRORS"); $errortext = $_[0]; @@ -2909,6 +2916,7 @@ sub _warn($$;$) { +apply_formats(); return 0 unless _verbosity("WARN") && ($::RD_HINT || $_[0] >= ($::RD_WARN||1)); $errortext = $_[1]; $errorprefix = "Warning" . ($_[2] ? " (line $_[2])" : ""); @@ -2920,6 +2928,7 @@ sub _hint($) { +apply_formats(); return 0 unless defined $::RD_HINT; $errortext = "$_[0])"; $errorprefix = "(Hint"; @@ -2968,6 +2977,7 @@ sub _trace($;$$$) { +apply_formats(); $tracemsg = $_[0]; $tracecontext = $_[1]||$lastcontext; $tracerulename = $_[2]||$lastrulename;
Subject: Re: [rt.cpan.org #52613] format are wonky with Perl 5.10
Date: Thu, 10 Dec 2009 16:23:23 +1100
To: bug-Parse-RecDescent [...] rt.cpan.org
From: Damian Conway <damian [...] conway.org>
Thanks, Ted, but I can't reproduce this under 5.10 on any of my systems. All the debugging information prints out as expected. Ubuntu's problem with the module is, frankly, a little puzzling. Damian
I kept trying to find the issue, no luck. I determined that simply moving all the formats to a function (as in apply_formats() in my patch) and calling that function once was sufficient. Without the function call, if the format calls were executed right after the filehandles were set up, I get blank output again. See my attached revised patch, with my change it all works without requiring apply_formats() calls every time. If I move the filehandle code to a test script, inside a package, it works fine. Something about the specific way P::RD does it is triggering the bug, and it feels like a scoping issue. I couldn't catch it with the Perl debugger but am open to suggestions how to proceed. I could go to comp.lang.perl.misc or p5porters but I'm trying to figure out why my particular environment is having this issue. Thanks Ted
--- /usr/local/share/perl/5.10.0/Parse/RecDescent.pm 2003-04-09 03:29:37.000000000 -0500 +++ Parse/RecDescent.pm 2009-12-10 11:29:16.000000000 -0600 @@ -2845,12 +2845,6 @@ my $errorprefix; open (ERROR, ">&STDERR"); -format ERROR = -@>>>>>>>>>>>>>>>>>>>>: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -$errorprefix, $errortext -~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - $errortext -. select ERROR; $| = 1; @@ -2863,27 +2857,39 @@ use vars '$tracelevel'; open (TRACE, ">&STDERR"); -format TRACE = + +select TRACE; +$| = 1; + +open (TRACECONTEXT, ">&STDERR"); + +select TRACECONTEXT; +$| = 1; + +apply_formats(); + +sub apply_formats +{ + format ERROR = +@>>>>>>>>>>>>>>>>>>>>: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +$errorprefix, $errortext +~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + $errortext +. + format TRACE = @>|@|||||||||@^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<| $tracelevel, $tracerulename, '|', $tracemsg | ~~ |^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<| $tracemsg . -select TRACE; -$| = 1; - -open (TRACECONTEXT, ">&STDERR"); -format TRACECONTEXT = + format TRACECONTEXT = @>|@|||||||||@ |^<<<<<<<<<<<<<<<<<<<<<<<<<<< $tracelevel, $tracerulename, '|', $tracecontext | ~~ | |^<<<<<<<<<<<<<<<<<<<<<<<<<<< $tracecontext . - - -select TRACECONTEXT; -$| = 1; +} select STDOUT;
Subject: Re: [rt.cpan.org #52613] format are wonky with Perl 5.10
Date: Fri, 11 Dec 2009 08:39:48 +1100
To: bug-Parse-RecDescent [...] rt.cpan.org
From: Damian Conway <damian [...] conway.org>
Show quoted text
> I kept trying to find the issue, no luck.  I determined that simply > moving all the formats to a function (as in apply_formats() in my patch) > and calling that function once was sufficient.
I'm much happier with your revised patch, as it fixes your problem, improves overall modularity, and doesn't have a run-time cost on other systems. I'll include it for the next release. Formats have a notorious history of not playing well with lexicals. It's odd that the issue only arises on your system (so far), but then most things I/O-related have *some* degree o system-dependence. Thanks for persisting with this, Ted. Patch applied. Damian
Subject: Re: [rt.cpan.org #52613] format are wonky with Perl 5.10
Date: Fri, 11 Dec 2009 08:48:56 +1100
To: bug-Parse-RecDescent [...] rt.cpan.org
From: Damian Conway <damian [...] conway.org>
Show quoted text
> I'm much happier with your revised patch, as it fixes your problem, > improves overall modularity, and doesn't have a run-time cost on > other systems. I'll include it for the next release.
Hmmmmm. In looking to apply the patch, I see that this issue was (supposedly!) addressed in the 1.95 release, by replacing all the lexicals with package variables. Your patch seems to be against an older release? Are you using the latest (1.962.2) Parse::RecDescent? If not, could you see if that already fixes your Ubuntu-specific problem? Damian
On Thu Dec 10 16:49:36 2009, damian@conway.org wrote: Show quoted text
> Hmmmmm. In looking to apply the patch, I see that this issue was > (supposedly!) addressed in the 1.95 release, by replacing all the > lexicals with package variables. Your patch seems to be against an
older Show quoted text
> release? Are you using the latest (1.962.2) Parse::RecDescent? If not, > could you see if that already fixes your Ubuntu-specific problem?
I thought I tested against the latest but it wasn't. It got installed with the wrong permissions, to make a long story short. Sorry for the trouble! Is there a "dumbass user" RT status? :) Ted
Subject: Re: [rt.cpan.org #52613] format are wonky with Perl 5.10
Date: Fri, 11 Dec 2009 10:50:39 +1100
To: bug-Parse-RecDescent [...] rt.cpan.org
From: Damian Conway <damian [...] conway.org>
Show quoted text
> I thought I tested against the latest but it wasn't.  It got installed > with the wrong permissions, to make a long story short.  Sorry for the > trouble!  Is there a "dumbass user" RT status? :)
<grin> Glad it working for you now. Damian