Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time::Local's croak calls cannot be silenced #7969

Closed
p5pRT opened this issue Jun 13, 2005 · 8 comments
Closed

Time::Local's croak calls cannot be silenced #7969

p5pRT opened this issue Jun 13, 2005 · 8 comments

Comments

@p5pRT
Copy link

p5pRT commented Jun 13, 2005

Migrated from rt.perl.org#36268 (status was 'resolved')

Searchable as RT36268$

@p5pRT
Copy link
Author

p5pRT commented Jun 13, 2005

From jr@terragate.net

Created by reith2@reliant.local

This is a bug report for perl from reith2@​reliant.local,
generated with the help of perlbug 1.35 running under perl v5.8.7.

-----------------------------------------------------------------
Expected result​: No output
Actual result​: Output of​:

Day too big - 25598 > 24855
Sec too small - 25598 < 78352
Sec too big - 25598 > 15247

Code (32 Bit Platforms only)​:

#!/usr/bin/perl -w

use Time​::Local;

eval {
  failure​::do_croak();
};

eval {
  local $SIG{'__WARN__'} # just to be sure;
  local $SIG{'__DIE__'} # just to be sure;
  # this will cause a failure on 32 Bit hosts
  timelocal(1,1,1,1,1,2040);
};

package failure;

use Carp;

sub do_croak {
  croak "This message should not appear";
}

Description​:

The first call to croak (i.e. die) works as expected. But the second ones error messages' can't be silenced with 5.8.6 & 5.8.7

With perl 5.8.0 (i386-linux-thread-multi) this problem does not occour

Perl Info

Flags:
    category=core
    severity=medium

Site configuration information for perl v5.8.7:

Configured by reith2 at Mon Jun 13 12:59:32 CEST 2005.

Summary of my perl5 (revision 5 version 8 subversion 7) configuration:
  Platform:
    osname=darwin, osvers=8.1.0, archname=darwin-2level
    uname='darwin reliant.local 8.1.0 darwin kernel version 8.1.0: tue may 10 18:16:08 pdt 2005; root:xnu-792.1.5.obj~4release_ppc power macintosh powerpc '
    config_args=''
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -I/opt/local/include',
    optimize='-O3',
    cppflags='-no-cpp-precomp -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -I/opt/local/include'
    ccversion='', gccversion='4.0.0 (Apple Computer, Inc. build 5026)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -L/usr/local/lib -L/opt/local/lib'
    libpth=/usr/local/lib /opt/local/lib /usr/lib
    libs=-ldbm -ldl -lm -lc
    perllibs=-ldl -lm -lc
    libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/usr/local/lib -L/opt/local/lib'

Locally applied patches:
    


@INC for perl v5.8.7:
    /usr/local/lib/perl5/5.8.7/darwin-2level
    /usr/local/lib/perl5/5.8.7
    /usr/local/lib/perl5/site_perl/5.8.7/darwin-2level
    /usr/local/lib/perl5/site_perl/5.8.7
    /usr/local/lib/perl5/site_perl
    .


Environment for perl v5.8.7:
    DYLD_LIBRARY_PATH (unset)
    HOME=/Users/reith2
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/opt/local/bin:/bin:/sbin:/usr/bin:/usr/sbin
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Jun 13, 2005

From @schwern

On Mon, Jun 13, 2005 at 11​:34​:57AM -0000, Jeremias Reith wrote​:

The first call to croak (i.e. die) works as expected. But the second ones error messages' can't be silenced with 5.8.6 & 5.8.7

That's because they're not part of the croak, they're warnings. Doing this

  eval {
  local $SIG{'__WARN__'} = sub {};
  timelocal(...);
  };

will silence everything. However, that's confusing. Since the warnings
only happen when timelocal is going to croak they might as well be part of
the croak message so its all trapped by the eval.

The attached patch makes the warnings part of the croak(). It also cleans
up the formatting a little so instead of this​:

  Day too big - 25598 > 24854
  Sec too small - 25598 < 74752

You get this​:

  Day too big​: 25598 > 24854
  Sec too small​: 25598 < 74752

This both lines up the numbers for easier reading and removes the somewhat
confusing "- 12345" formatting.

--
Michael G Schwern schwern@​pobox.com http​://www.pobox.com/~schwern
ROCKS FALL! EVERYONE DIES!
  http​://www.somethingpositive.net/sp05032002.shtml

@p5pRT
Copy link
Author

p5pRT commented Jun 13, 2005

From @schwern

tl.patch
--- lib/Time/Local.pm	2005/06/13 15:18:23	1.1
+++ lib/Time/Local.pm	2005/06/13 15:23:20
@@ -133,12 +133,17 @@
         or  ($days > $Min{Day} or $days == $Min{Day} and $xsec >= $Min{Sec})
        and  ($days < $Max{Day} or $days == $Max{Day} and $xsec <= $Max{Sec}))
     {
-        warn "Day too small - $days > $Min{Day}\n" if $days < $Min{Day};
-        warn "Day too big - $days > $Max{Day}\n" if $days > $Max{Day};
-        warn "Sec too small - $days < $Min{Sec}\n" if $days < $Min{Sec};
-        warn "Sec too big - $days > $Max{Sec}\n" if $days > $Max{Sec};
+        my $msg = '';
+        
+        $msg .= "Day too small: $days > $Min{Day}\n" if $days < $Min{Day};
+        $msg .= "Day too big:   $days > $Max{Day}\n" if $days > $Max{Day};
+        $msg .= "Sec too small: $days < $Min{Sec}\n" if $days < $Min{Sec};
+        $msg .= "Sec too big:   $days > $Max{Sec}\n" if $days > $Max{Sec};
 	$year += 1900;
-	croak "Cannot handle date ($sec, $min, $hour, $mday, $month, $year)";
+
+	$msg .= "Cannot handle date ($sec, $min, $hour, $mday, $month, $year)";
+
+        croak $msg;
     }
 
     no integer;

@p5pRT
Copy link
Author

p5pRT commented Jun 13, 2005

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jun 13, 2005

From tels@bloodgate.com

-----BEGIN PGP SIGNED MESSAGE-----

Moin,

Michael G Schwern <schwern@​pobox.com> wrote​:

On Mon, Jun 13, 2005 at 11​:34​:57AM -0000, Jeremias Reith wrote​:

The first call to croak (i.e. die) works as expected. But the second
ones error messages' can't be silenced with 5.8.6 & 5.8.7
That's because they're not part of the croak, they're warnings. Doing
this
[snipabit]

Michael, while you are there, could you please​:

* bump the version
* rewrite the Local.pm to only load Carp when actually needed? (there are
only two places, I think).

I Cc'ed this to Dave Rolsky and datetime@​perl.org, both emails are given
in the POD as support contacts. Let's see if they still work :)

Thanx,

Tels

- --
Signed on Mon Jun 13 19​:43​:29 2005 with key 0x93B84C15.
Visit my photo gallery at http​://bloodgate.com/photos/
PGP key on http​://bloodgate.com/tels.asc or per email.

"Given enough time, all legal battles in the tech industry will invoke
the DMCA. This generally means that all constructive arguments have
ended." NialScorva's law

-----BEGIN PGP SIGNATURE-----
Version​: GnuPG v1.2.4 (GNU/Linux)

iQEVAwUBQq3GxXcLPEOTuEwVAQGeVgf+Oari6ldLwryNCVVsStqRC2JdRgNFG8Jo
zAiaA461i8NeI8vGHth4re6d9FE4HARGQk9iiDp6stM/3gjFXhzo1qycJpcS/ypq
fX2K3dlix1+Yg7YL4OSD+K/sEozHCxNoMRDEEbaF5aIW2I2QSaf4gIe+JDt4MVaA
Sjbr65P/5pV1fPg/vUvC9vp9/hddevo5PgaDpCtXbivf51wzNItoSIHEKHRxt+Rn
PnaI0TmIh8ERQw6xystHDoP/0KZKZz34ir/YvJtlXXnI6EmeMnqidaK+bCSXfrU5
fcrD4k0hQVlxquovGQ6fb3pzjnxDOPtKlOQ62Ha9fBPIfBTTqv5T/g==
=RFhw
-----END PGP SIGNATURE-----

@p5pRT
Copy link
Author

p5pRT commented Jun 13, 2005

From @schwern

On Mon, Jun 13, 2005 at 07​:47​:36PM +0200, Tels wrote​:

* bump the version

I usually leave that to the bleadperl folks.

* rewrite the Local.pm to only load Carp when actually needed? (there are
only two places, I think).

Not as part of the same patch. I like to keep patches compartmentalized.
Anyhow, my itch has been scratched so no. Given that Carp is now split
into Carp and Carp​::Heavy I'm not even sure this is necessary anymore.

PS I wasn't aware there was a CPAN version.

--
Michael G Schwern schwern@​pobox.com http​://www.pobox.com/~schwern
Reality is that which, when you stop believing in it, doesn't go away.
  -- Phillip K. Dick

@p5pRT
Copy link
Author

p5pRT commented Jun 13, 2005

From tels@bloodgate.com

-----BEGIN PGP SIGNED MESSAGE-----

Moin,

On Monday 13 June 2005 21​:41, Michael G Schwern wrote​:

On Mon, Jun 13, 2005 at 07​:47​:36PM +0200, Tels wrote​:

* bump the version

I usually leave that to the bleadperl folks.

I think that whoever applies the patch has an easier life if you bump up
the version right away, lest it be forgotten. (If I am wrong, somebody
please correct me)

* rewrite the Local.pm to only load Carp when actually needed? (there
are only two places, I think).

Not as part of the same patch. I like to keep patches
compartmentalized.

I know, but I thought it would be easier for you to write a followup
patch, because I would have to sync blead, apply your patch, then prepare
a new one, while you could just have started a new one.

Sorry for the shameless attempt to offload work. WIll not happen again.

Anyhow, my itch has been scratched so no. Given
that Carp is now split into Carp and Carp​::Heavy I'm not even sure this
is necessary anymore.

I think so​:

  PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
W/o​:
11490 te 16 0 3912 1220 1048 S 0.0 0.1 0​:00.00 perl
With​:
11509 te 17 0 4044 1472 1212 S 0.0 0.1 0​:00.00 perl

That are 132 Kbyte (depending on which memory stat you look) difference
under Perl v5.8.6 :)

Best wishes,

Tels

- --
Signed on Mon Jun 13 22​:01​:52 2005 with key 0x93B84C15.
Visit my photo gallery at http​://bloodgate.com/photos/
PGP key on http​://bloodgate.com/tels.asc or per email.

"The campaign should combat the messages of pornography by putting signs
on buses saying sex with children is not OK." -- Mary Anne Layden in
ttp​://tinyurl.com/6a9cy

-----BEGIN PGP SIGNATURE-----
Version​: GnuPG v1.2.4 (GNU/Linux)

iQEVAwUBQq3n5HcLPEOTuEwVAQGCFgf9FyKRDPhNGpyoDJZ5xLMtoT2y8wTOzNO6
nzNr7obLn3pCkHTTgsLn42sdSdISSV2SBMkbGLT+fyuS09CMM0xjjRjiwYwSgw8p
C4jplMzC29+ddAO4M/tS7jTO0ZH7VJKWZGj8qb1a9KC78Y0vCC8Z2vW7CnPDXkI/
q8DwZufx8Kohv128iWEAhM1rEX5w6bZFX+PUciHjsLVf1Inv3DRW71it8sJkCHJA
BbLgAeh4Eu97Knoa3FwUzEwflVMp8RsjgsGv3gqFPuSyaYAuj3RT0l8RhrtjkpJ7
pssPt8bIF8lJnw0aaibhAbBOGhXZDuB2m7NKf9RVqK9m256qP/NOfQ==
=YEVW
-----END PGP SIGNATURE-----

@p5pRT
Copy link
Author

p5pRT commented Jan 24, 2007

@rspier - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant