Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: A possable bug in the "warnings" pragma.

2 views
Skip to first unread message

A. Sinan Unur

unread,
Aug 5, 2006, 7:20:27 PM8/5/06
to
Dale Wiles <WilesI...@IgnoreMeModArnis.Com> wrote in
news:36kf5ov...@IgnoreMeModArnis.Com:

> 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.

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.

> 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.

...

> ---- perl_warnings ----
>
> #!/usr/bin/perl
>
> package Foo;
> use strict;
> use warnings::register;
>
> sub new($)

Why are you using prototypes with methods?

> {
> my ($self) = @_;
>
> my $class = { };
> bless $class, $self;
>
> return $class;
> }

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;
}

>
> sub warnme($$)

Ditto. No point in having prototypes with warnings.

> {
> my ($self, $text) = @_;
>
> warnings::warnif($self, $text);

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);

D:\UseNet\clpmisc> cat t97.pl
#!/usr/bin/perl

package Foo;

use strict;
use warnings::register;

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

sub warnme {
my $self = shift;
my ($text) = @_;
warnings::warnif(Foo => $text);
}

package main;

use strict;
use warnings;

sub wtest {
my $f = shift;
$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.');


D:\UseNet\clpmisc> t97
Saw me. at D:\UseNet\clpmisc\t97.pl line 26
Killed me. at D:\UseNet\clpmisc\t97.pl line 30

Sinan
--
A. Sinan Unur <1u...@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html

A. Sinan Unur

unread,
Aug 5, 2006, 7:28:27 PM8/5/06
to
"A. Sinan Unur" <1u...@llenroc.ude.invalid> wrote in
news:Xns9816C4D74D5...@127.0.0.1:

> Dale Wiles <WilesI...@IgnoreMeModArnis.Com> wrote in
> news:36kf5ov...@IgnoreMeModArnis.Com:

...

>> sub warnme($$)
>
> Ditto. No point in having prototypes with warnings.

Of course, s/warnings/methods/.

Sorry.

Mumia W.

unread,
Aug 5, 2006, 10:11:50 PM8/5/06
to
On 08/05/2006 06:20 PM, A. Sinan Unur wrote:
> Dale Wiles <WilesI...@IgnoreMeModArnis.Com> wrote in
> news:36kf5ov...@IgnoreMeModArnis.Com:
>
>> 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"


A. Sinan Unur

unread,
Aug 5, 2006, 10:31:52 PM8/5/06
to
"Mumia W." <mumia.w.18.spa...@earthlink.net> wrote in news:GdcBg.70$Sn...@newsread3.news.pas.earthlink.net:

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.lang.perl.misc/browse_frm/thread/01d1fa7f1c131045/45ce76dfdaff24dc#45ce76dfdaff24dc

http://groups.google.com/groups?selm=36kf5ovh19w.vyr%40IgnoreMeModArnis.Com

There is something odd going on.

use...@davidfilmer.com

unread,
Aug 6, 2006, 3:22:56 AM8/6/06
to
A. Sinan Unur wrote:

> 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).

--
David Filmer (http://DavidFilmer.com)

Dr.Ruud

unread,
Aug 6, 2006, 7:22:32 AM8/6/06
to
use...@DavidFilmer.com schreef:
> A. Sinan Unur:

>> 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).

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/

--
Affijn, Ruud

"Gewoon is een tijger."


A. Sinan Unur

unread,
Aug 6, 2006, 10:30:22 AM8/6/06
to
"Dr.Ruud" <rvtol...@isolution.nl> wrote in news:eb4qqr.1go.1
@news.isolution.nl:

> use...@DavidFilmer.com schreef:
>> A. Sinan Unur:
>
>>> By the way, Google Groups has not heard of this message yet:
>>
>> That's not terribly uncommon.

Well, it was a first for me. Given that both Google and XNews tripped up
and stored the message with the following headers

From ???@0x00000A3B Sat Dec 30 04:00:00 1899
Path: ...!news.newsgroup-binaries.com!not-for-mail
Newsgroups: comp.lang.perl.misc
Subject: A possable bug in the "warnings" pragma.
From: Dale Wiles <WilesI...@IgnoreMeModArnis.Com>
Sender: WilesI...@IgnoreMeModArnis.Com


Date: Sat Aug 5 22:57:29 2006 +0000

Message-ID: <36kf5ov...@IgnoreMeModArnis.Com>
User-Agent: Nntp_post 1.1
Lines: 77
Organization: newsgroup-binaries.com
X-Complaints-To: ab...@newsgroup-binaries.com
Xref: wnmaster11 comp.lang.perl.misc:586085
X-Received-Date: Sat, 05 Aug 2006 22:57:29 GMT (bgtnsc05-
news.ops.worldnet.att.net)

I figured a configuation issue somewhere. Anyway, moving on ...

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

;-) Just to be make it really, really clear, it is not that there are no
bugs left in perl or the core distribution. Some people just do not try
hard enough on their own code before claiming to have found such a bug.

#11907 Looking for a compiler bug is the strategy of LAST resort. LAST
resort.

http://groups.google.com/group/comp.lang.perl.misc/msg/b2f911d6d9c5cef2

> 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/

Thanks for the link.

Ben Morrow

unread,
Aug 6, 2006, 10:36:11 AM8/6/06
to

Quoth "A. Sinan Unur" <1u...@llenroc.ude.invalid>:

This is functionally equivalent to what the OP had. The only difference
is he had then names $self and $class the wrong way round.

> >
> > sub warnme($$)
>
> Ditto. No point in having prototypes with warnings.
>
> > {
> > my ($self, $text) = @_;
> >
> > warnings::warnif($self, $text);
>
> 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

--
You poor take courage, you rich take care:
The Earth was made a common treasury for everyone to share
All things in common, all people one. [benm...@tiscali.co.uk]
'We come in peace'---the order came to cut them down.

A. Sinan Unur

unread,
Aug 6, 2006, 12:54:00 PM8/6/06
to
Ben Morrow <benm...@tiscali.co.uk> wrote in
news:rbbhq3-...@osiris.mauzo.dyndns.org:

>
> Quoth "A. Sinan Unur" <1u...@llenroc.ude.invalid>:
>> Dale Wiles <WilesI...@IgnoreMeModArnis.Com> wrote in
>> news:36kf5ov...@IgnoreMeModArnis.Com:

...

Of course. And that was my point. Using the wrong words for things was a
read flag to me.

>> > warnings::warnif($self, $text);
>>
>> 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.

That it does (which I had missed).

> 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.

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.

Just for the record, here is the shortened version of the original script
which I have been playing around with:

#!/usr/bin/perl

package Foo;

use strict;
use warnings::register;

sub new { bless { } => $_[0] }

# FATAL is not obeyed
sub warnme { warnings::warnif(shift, shift) }

# FATAL is obeyed
# sub warnme { shift; warnings::warnif(shift) }

# FATAL is obeyed
# sub warnme { warnings::warnif(ref shift, shift) }

package main;

use strict;
use warnings;

sub wtest {
my $f = shift;
$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.');

__END__

ax...@white-eagle.invalid.uk

unread,
Aug 6, 2006, 8:23:14 PM8/6/06
to
A. Sinan Unur <1u...@llenroc.ude.invalid> wrote:
> "Mumia W." <mumia.w.18.spa...@earthlink.net> wrote in news:GdcBg.70$Sn...@newsread3.news.pas.earthlink.net:

>>> Dale Wiles <WilesI...@IgnoreMeModArnis.Com> wrote in
>>> news:36kf5ov...@IgnoreMeModArnis.Com:

>>> 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.

>> Nope, Seamonkey says it was posted today, and the date header

>> says "Date: Sat Aug 5 22:57:29 2006 +0000"

> 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.lang.perl.misc/browse_frm/thread/01d1fa7f1c131045/45ce76dfdaff24dc#45ce76dfdaff24dc
> http://groups.google.com/groups?selm=36kf5ovh19w.vyr%40IgnoreMeModArnis.Com

> 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


Dr.Ruud

unread,
Aug 6, 2006, 8:52:34 PM8/6/06
to
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...

ax...@white-eagle.invalid.uk

unread,
Aug 6, 2006, 9:19:44 PM8/6/06
to

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

Dale Wiles

unread,
Aug 8, 2006, 9:36:56 PM8/8/06
to

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?

--
Dale Wiles
Remove IgnoreMe from my address to email.
-----------------
www.Newsgroup-Binaries.com - *Completion*Retention*Speed*
Access your favorite newsgroups from home or on the road
-----------------

anno...@radom.zrz.tu-berlin.de

unread,
Aug 9, 2006, 6:11:19 AM8/9/06
to
A. Sinan Unur <1u...@llenroc.ude.invalid> wrote in comp.lang.perl.misc:

> Ben Morrow <benm...@tiscali.co.uk> wrote in
> news:rbbhq3-...@osiris.mauzo.dyndns.org:
> > Quoth "A. Sinan Unur" <1u...@llenroc.ude.invalid>:
> >> Dale Wiles <WilesI...@IgnoreMeModArnis.Com> wrote in
> >> news:36kf5ov...@IgnoreMeModArnis.Com:
> ...
> >> > This program, posted below, should die at "Killed me.". If I run
> >> > it I get:

[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

0 new messages