bcrowell2 has asked for the wisdom of the Perl Monks concerning the following question:

I seem to have stumbled across a bug in Perl 5.8.4, and I'm wondering if anyone else can help me confirm it's a bug.

Basically I have a piece of software here containing a module Browser.pm. It's been running fine for me on FreeBSD with perl 5.8.5 (and also on some earlier versions of perl), and I have users running it ok on Mandrake and Windows. However, I find that on perl 5.8.4 on Debian-Sarge, if I do "perl -c Browser.pm", perl goes into an endless loop, eating CPU like crazy. I'd appreciate it greatly if anyone could supply more data points, by downloading the tarball and running a perl -c on it on their own system. At this point I'm not sure if (a) it's a bug in perl 5.8.4 that was fixed in 5.8.5, (b) it's a bug in the version of perl being distributed with Debian-sarge, or (c) there's something else going on that I don't understand. If it's a, then I guess I just post a notice on my web page saying my software is known not to work with 5.8.4. If it's b, then maybe I should report it as a bug to Debian. If it's c, then maybe it's a bug in perl that I should report, or...?

TIA!

Thanks, all, for your help! The suggestion about the BEGIN block was bang on -- I'd been assuming that Perl would just be checking the syntax, didn't realize it was doign the BEGIN blocks. The following turns out to be a somewhat more minimal example:

eval "use Audio::Data"; my ($server,$sound); eval { # Don't crash and burn if they don't have Audio installed. my $silent = Audio::Data->new(rate=>44100.); my $shk = Audio::Data->new(rate=>44100.); my $delay = 0.06; # so it doesn't occur at the same instant as the + sound of the clicking key my $duration = 0.05; $silent->silence($delay); $shk->noise($duration,1.6); my $n = $shk->samples; my $attack_frac = .1; for (my $i=0; $i<=$n; $i++) { my $attack = 1.; if ($i<$n*$attack_frac) {$attack=$i/($n*$attack_frac)} my $tail = ($n-$i)/$n; my $env = $attack*$attack*$tail*$tail*$tail; $shk->[$i] *= $env; } $sound = Audio::Data->new(rate=>44100.); $sound = $silent . $shk; };
Interestingly, it seems to be very hard to take any code out of this without curing the bug. So the long and the short of it seems to be that it's a bug in Audio::Data.

Replies are listed 'Best First'.
Re: bug in perl 5.8.4?
by conrad (Beadle) on Dec 07, 2004 at 12:08 UTC

    Under Perl 5.8.4 (i386-linux-thread-multi) on Debian unstable it runs fine (syntax OK). It's usually helpful in such situations to strip your program down until you have the minimum piece of code which exhibits the problem.

    Note that -c executes BEGIN blocks among other things, and you've quite a bit of code in your BEGINs. Suggest you start there.

Re: bug in perl 5.8.4?
by fraterm (Scribe) on Dec 07, 2004 at 05:42 UTC
    I can help with the gentoo dist, though the perl I have running in it is at version 5.8.5. Sadly my gentooishness is always on the ~x86 bleeding edge of things... May want to check changelog entries... I may do so just to investigate as well. From running and downloading I recieved no endless loop. But i don't have Tk.pm so I'll try again after installing (ewwww... ) ;)
    Squibbie Pooh Ski Doo.
      Yeah, Tk.pm is humongous, unfortunately...thanks for your efforts!! Looking forward to hearing more.

        • Perl version 5.8.5
        • Tk.pm version 804.027
        • Date-Calc 5.4
        • dev-perl/Clone 0.15
        • dev-perl/TermReadKey 2.21

        After all that and whatever else it required it runs fine, I suspect, as I'ven't read the manual yet.

        The only problem that comes to mind that would cause some misbehavior like this would be the TermUI.pmperhaps in conjunction with Term::ReadKey stuff getting "wackadoo" this is a wild guess. Who knows it might narrow things down.

        The reason for my suspicion is that I noticed it takes much longer than I feel comfortable with to absorb a CTRL+Z and CTRL+C from the keyboard.

        This might be one of those edge cases where... Perl 5.8.4 + whatever other versions of modules the user in question posesses and perhaps even more insidious whatever other versions of C style system libraries that they wrap/depend might be leaking oil so to speak with the users particular Debian (kernel/libs/perl+TK depends) stew... HTH.

        Squibbie Pooh Ski Doo.
Re: bug in perl 5.8.4?
by PreferredUserName (Pilgrim) on Dec 07, 2004 at 15:49 UTC
    Try strace -f perl -c Browser.pm to see if he's actually doing any real work, or if he's stuck somehow.