A possable bug in the "warnings" pragma.

D

Dale Wiles

I think I found a bug in perl's "warnings" pragma, but I want to
make sure that it's an actual, reproducible bug before reporting it.

This program, posted below, should die at "Killed me.". If I run
it I get:

Saw me. at perl_warnings_fails line 36
Killed me. at perl_warnings_fails line 40
Revenge from beyond the grave! at perl_warnings_fails line 43
Out of the function. at perl_warnings_fails line 48

If I uncomment "my $y = \@_;"

Saw me. at perl_warnings_fails line 36
Killed me. at perl_warnings_fails line 40

which is what's expected.

There's nothing special about "my $y = \@_;". Pretty much anything
that touches "@_" masks the bug. "@_ = ();" works as does "print \@;"
That's why I think it's a bug in the Perl interpreter.

I'm using perl, v5.8.7 built for i486-linux. If someone has 5.8.8 I'd
especially appreciate hearing from them.

Dale (Don't really IgnoreMe) Wiles

---- perl_warnings ----

#!/usr/bin/perl

package Foo;
use strict;
use warnings::register;

sub new($)
{
my ($self) = @_;

my $class = { };
bless $class, $self;

return $class;
}

sub warnme($$)
{
my ($self, $text) = @_;

warnings::warnif($self, $text);
}

1;

package main;
use strict;
use warnings;

sub wtest($)
{
my $f = shift;

# my $y = \@_;

$f->warnme('Saw me.');

{
use warnings FATAL => 'Foo';
$f->warnme('Killed me.');
}

$f->warnme('Revenge from beyond the grave!');
}

my $g = Foo->new;
wtest($g);
$g->warnme('Out of the function.');
 
M

Mumia W.

I think I found a bug in perl's "warnings" pragma, but I want to
make sure that it's an actual, reproducible bug before reporting it.

Well, I have to tell you, there seems to be a problem with your posting
software. XNews thinks this post was made on 30 Dec 1899.
[...]

<OT>
Nope, Seamonkey says it was posted today, and the date header
says "Date: Sat Aug 5 22:57:29 2006 +0000"
 
U

usenet

A. Sinan Unur said:
By the way, Google Groups has not heard of this message yet:

That's not terribly uncommon. I even responded once to a GG post (in
GG) only to discover the original post went away and only my answer
remained. Very strange.

FWIW, whenever anyone claims a Perl core bug, the first thing I suspect
is a hardware issue (probably a loose nut behind the keyboard).
 
D

Dr.Ruud

(e-mail address removed) schreef:
A. Sinan Unur:

That's not terribly uncommon. I even responded once to a GG post (in
GG) only to discover the original post went away and only my answer
remained. Very strange.

FWIW, whenever anyone claims a Perl core bug, the first thing I
suspect is a hardware issue (probably a loose nut behind the
keyboard).

There is a recent discussion on the ietf-usefor mailing list about
X-No-Archive and such, which also has pointers on how to remove a
posting from the google archives.
http://article.gmane.org/gmane.ietf.usenet.format/30965/
 
B

Ben Morrow

Quoth "A. Sinan Unur said:
Well, I have to tell you, there seems to be a problem with your posting
software. XNews thinks this post was made on 30 Dec 1899.

I'll have to say up front, I am always skeptical of people whose first
post starts with a claim that they have found a bug in Perl or core Perl
modules.


Why are you using prototypes with methods?


You have the concepts mixed up here: New is passed the name of the
package as its first argument. Then, you bless an instance into that
package, returned the blessed reference which is the instance of the
class. Hence, your new method, in this case, should be:

sub new {
my $class = shift;
bless { }, $class;
}

This is functionally equivalent to what the OP had. The only difference
is he had then names $self and $class the wrong way round.
Ditto. No point in having prototypes with warnings.


Now, your confusion with classes and instances carries over here. The
category you have created is called 'Foo'. Do you think $self eq 'Foo'?

Replace this with:

warnings::warnif(Foo => $text);

warnings::warnif (claims to) accept an object and use that object's
class as the category.

In any case explicitly specifying te category is not a good idea. In a
method you should probably use ref $self; in a function just use 1-param
warnif that uses the current package.

Ben
 
A

axel

Well, I see that information in the message headers too. However,
in the message listing window, I see the 1899 date.

By the way, Google Groups has not heard of this message yet:
http://groups.google.com/group/comp...a7f1c131045/45ce76dfdaff24dc#45ce76dfdaff24dc
http://groups.google.com/[email protected]
There is something odd going on.

My newsreader (tin) shows the date as being 'Wed, 31 Dec 1969
15:59:59' for the OP's article in its summary information at the
top of the message. I don't see where it can be getting that
information... unless perhaps the OP's use of an obsolete/invalid
format for the 'Date:' header field is causing the screw-up.

Axel
 
D

Dr.Ruud

axel schreef:
My newsreader (tin) shows the date as being 'Wed, 31 Dec 1969
15:59:59' for the OP's article in its summary information at the
top of the message. I don't see where it can be getting that
information... unless perhaps the OP's use of an obsolete/invalid
format for the 'Date:' header field is causing the screw-up.

That is epoch -8 hours. Your EDT is GMT-4, so maybe your tin subtracted
twice...
 
A

axel

Dr.Ruud said:
axel schreef:
That is epoch -8 hours. Your EDT is GMT-4, so maybe your tin subtracted
twice...

Ah... I'ma actually in PDT although it seems that my news server is
using EDT. It makes sense... tin cannot cope with the invalid Date: and
so its date routine returns one second less than the epoch, i.e. -1.

Axel
 
D

Dale Wiles

I've gotten a lot of commentary about this post, (most about my rotten
news poster, I'm trying a new one.)

I've also got confirmation that the bug exists (either in my code or the
compiler) on other systems so it isn't a screw up on my install.

What I didn't get was which versions of Perl showed the weird behavior.

I assume that "A. Sinan Unur" is on a Windows box, but which version of
Perl are you running? Has anyone run it on a recent version of Perl
and not got the weirdness? Has anyone run it on v5.8.8?
 
A

anno4000

[big snip]
I have confirmed that both:

warnings::warnif(ref $self, $text);

and

warnings::warnif($text);

result in the expected behavior.

However,

warnings::warnif($self, $text);

results in FATAL not being obeyed.

I did some single stepping, inspecting bitmasks etc, but I haven't been
able to come up with a satisfactory explanation for this.

Last time I looked at the code in lib/warnings.pm that deals with the
method call of warnif() I found it entirely incomprehensible. It's
in sub __chk(), if anyone cares. Not that my incomprehension proves
anything, but in view of this bug I'd recommend no to use the method
call until someone has found the time to go over it again. The bug
is still in 5.8.8 and bleadperl (5.9.4).

Anno
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top