Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the ack CPAN distribution.

Maintainer(s)' notes

ack's issues are tracked at https://github.com/petdance/ack2

Report information
The Basics
Id: 23521
Status: resolved
Worked: 15 min
Priority: 0/
Queue: ack

People
Owner: Nobody in particular
Requestors: david.dyck [...] fluke.com
Cc:
AdminCc:

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



Subject: standalone (crushed) version of ack bombs immediately
Date: Tue, 21 Nov 2006 02:30:18 -0800 (PST)
To: bug-ack [...] rt.cpan.org
From: David Dyck <david.dyck [...] fluke.com>
I downloaded the standalone version of ack from http://petdance.com/ack/ack.txt and renamed it as ack but when I try to run it I get the following error Use of uninitialized value in subroutine entry at /usr0/dcd/bin/ack line 806. Can't use string ("") as a subroutine ref while "strict refs" in use at /usr0/dcd/bin/ack line 806. I get the same error when I make crush from the svn archive
On Tue Nov 21 05:32:34 2006, david.dyck@fluke.com wrote: Show quoted text
> I downloaded the standalone version of ack from > http://petdance.com/ack/ack.txt > > and renamed it as ack > > but when I try to run it I get the following error > > Use of uninitialized value in subroutine entry at /usr0/dcd/bin/ack > line 806.
Can you show me the lines around 806, as well as line 806?
Subject: Re: [rt.cpan.org #23521] standalone (crushed) version of ack bombs immediately
Date: Tue, 21 Nov 2006 22:23:13 -0800 (PST)
To: Andy Lester via RT <bug-ack [...] rt.cpan.org>
From: David Dyck <david.dyck [...] fluke.com>
On Tue, 21 Nov 2006 at 21:27 -0800, Andy Lester via RT <bug-ack@rt.cpan.org...: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=23521 > > > On Tue Nov 21 05:32:34 2006, david.dyck@fluke.com wrote:
>> I downloaded the standalone version of ack from >> http://petdance.com/ack/ack.txt >> >> and renamed it as ack >> >> but when I try to run it I get the following error >> >> Use of uninitialized value in subroutine entry at /usr0/dcd/bin/ack >> line 806.
> > Can you show me the lines around 806, as well as line 806?
dd:ack$ perl -nle 'print "$.:$_" if 803 .. 808' crush 803: 804: # Any leftover keys are bogus 805: for my $badkey ( keys %passed_parms ) { 806: $parms->{error_handler}->( "Invalid parameter passed to files(): $badkey" ); 807: } 808: dd:ack$ perl -d ./crush crush Loading DB routines from perl5db.pl version 1.28 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(./crush:6): our $COPYRIGHT = 'Copyright 2005-2006 Andy Lester, all rights reserved.'; DB<1> b 806 DB<2> c File::Next::files(./crush:806): $parms->{error_handler}->( "Invalid parameter passed to files(): $badkey" ); DB<2> x \%passed_parms 0 HASH(0x846f990) 'descend_filter' => CODE(0x8436070) -> &App::Ack::skipdir_filter in ./crush:380-382 'error_handler' => CODE(0x8547f80) -> &main::__ANON__[./crush:143] in ./crush:143-143 'file_filter' => CODE(0x84018b8) -> &main::is_interesting in ./crush:157-166 DB<3> x $badkey 0 'descend_filter' DB<4> x $parms 0 HASH(0x854fe68) empty hash
From: JMUHLICH [...] cpan.org
The problem goes away if you move the inlined packages up before the main code, and insert "package main;" after that, or wrap the appended packages in a BEGIN {}. (would that have any unexpected side-effects?) I'll try to make a patch that implements the latter.
Here's the patch. Seems to work, didn't text extensively though.
diff -ur ack-1.32/Makefile.PL ack-1.32-jmuhlich/Makefile.PL --- ack-1.32/Makefile.PL 2006-11-21 22:54:00.000000000 -0500 +++ ack-1.32-jmuhlich/Makefile.PL 2006-12-05 15:30:27.000000000 -0500 @@ -44,7 +44,9 @@ standalone: \$(ACK) \$(APP_ACK_PM) \$(FILE_NEXT_PM) grep -v 'use App::Ack' \$(ACK) | grep -v 'use File::Next' > \$(STANDALONE) + echo 'BEGIN {' >> \$(STANDALONE) cat \$(APP_ACK_PM) \$(FILE_NEXT_PM) >> \$(STANDALONE) + echo '}' >> \$(STANDALONE) chmod +x \$(STANDALONE) MAKE_FRAG
Subject: Re: [rt.cpan.org #23521] standalone (crushed) version of ack bombs immediately
Date: Tue, 5 Dec 2006 17:02:41 -0600
To: bug-ack [...] rt.cpan.org
From: Andy Lester <andy [...] petdance.com>
On Dec 5, 2006, at 2:27 PM, via RT wrote: Show quoted text
> The problem goes away if you move the inlined packages up before the > main code, and insert "package main;" after that, or wrap the appended > packages in a BEGIN {}. (would that have any unexpected side- > effects?) > I'll try to make a patch that implements the latter.
Please don't yet. I want to investigate further. I can't get it to fail in the first place. -- Andy Lester => andy@petdance.com => www.petdance.com => AIM:petdance
Subject: Re: [rt.cpan.org #23521] standalone (crushed) version of ack bombs immediately
Date: Tue, 5 Dec 2006 21:35:13 -0800 (PST)
To: "andy [...] petdance.com via RT" <bug-ack [...] rt.cpan.org>
From: David Dyck <david.dyck [...] fluke.com>
On Tue, 5 Dec 2006 at 16:22 -0800, andy@petdance.com via RT <bug-ack@rt.cpa...: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=23521 > > > > On Dec 5, 2006, at 2:27 PM, via RT wrote: >
>> The problem goes away if you move the inlined packages up before the >> main code, and insert "package main;" after that, or wrap the appended >> packages in a BEGIN {}. (would that have any unexpected side- >> effects?) >> I'll try to make a patch that implements the latter.
> > Please don't yet. I want to investigate further. I can't get it to > fail in the first place.
I just tested again with rev 89, and the BEGIN { } hint was a clue to me, as you can see from the patch below, that my File::Next was declaring a hash (that is used in its "sub files") that needs to be initialized before someone calls File::Next::files. When File::Next::files is "used", the file is read in at compile (BEGIN) time, and the hash is initialized, but when it is just "included", and put at the end of the file, the hash is not included before File::Next::files is called. Since you are having trouble reproducing the problem, what version of File::Next are you using? $ perldoc -l File::Next /usr/local/lib/perl5/site_perl/5.9.4/File/Next.pm $ grep VERSION /usr/local/lib/perl5/site_perl/5.9.4/File/Next.pm =head1 VERSION our $VERSION = '0.30'; $ perl -v This is perl, v5.9.4 built for i686-linux .... This just shows what I needed to do to get the ack-standalone.txt file to run. --- ack-standalone.txt.as-built Tue Dec 5 21:19:01 2006 +++ ack-standalone.txt Tue Dec 5 21:19:36 2006 @@ -471,12 +471,15 @@ our $name; # name of the current file our $dir; # dir of the current file -my %files_defaults = ( +my %files_defaults; +BEGIN { + %files_defaults = ( file_filter => sub{1}, descend_filter => sub {1}, error_handler => sub { CORE::die @_ }, sort_files => undef, ); +} sub files { my $passed_parms = ref $_[0] eq 'HASH' ? {%{+shift}} : {}; # copy parm hash If I apply the following patch to Makefile.pl, (putting File::Next before the main code) like the following patch, then get a successful standalone perl script. Index: Makefile.PL =================================================================== --- Makefile.PL (revision 89) +++ Makefile.PL (working copy) @@ -43,8 +43,8 @@ STANDALONE = ack-standalone.txt standalone: \$(ACK) \$(APP_ACK_PM) \$(FILE_NEXT_PM) - grep -v 'use App::Ack' \$(ACK) | grep -v 'use File::Next' > \$(STANDALONE) - cat \$(FILE_NEXT_PM) \$(APP_ACK_PM) >> \$(STANDALONE) + cat \$(FILE_NEXT_PM) \$(APP_ACK_PM) > \$(STANDALONE) + grep -v 'use App::Ack' \$(ACK) | grep -v 'use File::Next' >> \$(STANDALONE) chmod +x \$(STANDALONE) MAKE_FRAG
Subject: Re: [rt.cpan.org #23521] standalone (crushed) version of ack bombs immediately
Date: Tue, 5 Dec 2006 21:48:08 -0800 (PST)
To: via RT <bug-ack [...] rt.cpan.org>
From: David Dyck <david.dyck [...] fluke.com>
On Tue, 5 Dec 2006 at 12:27 -0800, via RT <bug-ack@rt.cpan.org> wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=23521 > > > The problem goes away if you move the inlined packages up before the > main code, and insert "package main;" after that, or wrap the appended > packages in a BEGIN {}. (would that have any unexpected side-effects?) > I'll try to make a patch that implements the latter.
I think that the first solution "move the inlined packages up before the main code, and insert "package main;" after that" is better than what reordering that I proposed, (as I forgot to add "package main;", and the BEGIN { } would allow the inserted code to be put at the end, which some may find more desireable. The line numbers have changed since the initial bug report againse "crusn" so here are the relavent lines again (with a little more context). $ perl ack-standalone.txt standalone Use of uninitialized value in subroutine entry at ack-standalone.txt line 492. Can't use string ("") as a subroutine ref while "strict refs" in use at ack-standalone.txt line 492. $ perl -nle 'print "$.:$_" if 473 .. 493' ack*sta*txt 473: 474:my %files_defaults = ( 475: file_filter => sub{1}, 476: descend_filter => sub {1}, 477: error_handler => sub { CORE::die @_ }, 478: sort_files => undef, 479:); 480: 481:sub files { 482: my $passed_parms = ref $_[0] eq 'HASH' ? {%{+shift}} : {}; # copy parm hash 483: my %passed_parms = %{$passed_parms}; 484: 485: my $parms = {}; 486: for my $key ( keys %files_defaults ) { 487: $parms->{$key} = delete( $passed_parms{$key} ) || $files_defaults{$key}; 488: } 489: 490: # Any leftover keys are bogus 491: for my $badkey ( keys %passed_parms ) { 492: $parms->{error_handler}->( "Invalid parameter passed to files(): $badkey" ); 493: }
It's all fixed in 1.34. I changed File::Next and App::Ack to do all their initialization inside BEGIN {} blocks.
Subject: Re: [rt.cpan.org #23521] standalone (crushed) version of ack bombs immediately
Date: Thu, 7 Dec 2006 22:21:21 -0800 (PST)
To: Andy Lester via RT <bug-ack [...] rt.cpan.org>
From: David Dyck <david.dyck [...] fluke.com>
Thanks, I noticed some changes, and was going to get back to you. Oh, can I put in a vote for the patch to not follow symbolic links to other directories -- it was very hard to use ack until then. Daavid On Thu, 7 Dec 2006 at 21:30 -0800, Andy Lester via RT <bug-ack@rt.cpan.org>...: Show quoted text
> From: Andy Lester via RT <bug-ack@rt.cpan.org> > To: "Dyck, David" <david.dyck@fluke.com> > Date: Thu, 7 Dec 2006 21:30:37 -0800 > Subject: [rt.cpan.org #23521] standalone (crushed) version of ack bombs > immediately > > > <URL: http://rt.cpan.org/Ticket/Display.html?id=23521 > > > It's all fixed in 1.34. I changed File::Next and App::Ack to do all > their initialization inside BEGIN {} blocks. >