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

"use base" masks $SIG{__DIE__} #8851

Closed
p5pRT opened this issue Mar 29, 2007 · 13 comments
Closed

"use base" masks $SIG{__DIE__} #8851

p5pRT opened this issue Mar 29, 2007 · 13 comments

Comments

@p5pRT
Copy link

p5pRT commented Mar 29, 2007

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

Searchable as RT42163$

@p5pRT
Copy link
Author

p5pRT commented Mar 29, 2007

From @schwern

Created by @schwern

If a module sets a global $SIG{__DIE__} handler and is loaded with "use base" that $SIG{__DIE__} handler will be localized and thus not set.

This is because of this code in base.pm.

  local $SIG{__DIE__};
  eval "require $base";

aliased.pm had a similar problem and I propose a similar fix.
http​://rt.cpan.org/Public/Bug/Display.html?id=25293

Patch forthcoming.

Perl Info

Flags:
    category=library
    severity=low

Site configuration information for perl v5.8.8:

Configured by schwern at Sat Oct 14 18:47:46 PDT 2006.

Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
  Platform:
    osname=darwin, osvers=8.8.1, archname=darwin-thread-multi-2level
    uname='darwin windhund.local 8.8.1 darwin kernel version 8.8.1: mon sep 25 19:42:00 pdt 2006; root:xnu-792.13.8.obj~1release_i386 i386 i386 macbook1,1 darwin '
    config_args='-Dprefix=/usr/local/perl/5.8.8 -Duseithreads -Dccflags=-I/sw/include -Dldflags=-L/sw/lib -Dperladmin=schwern@pobox.com -Dcf_email=schwern@pobox.com -Dmyhostname=windhund -Dmydomain=.schwern.org -Dprivlib=/usr/local/perl/5.8.8/lib -Dsiteprefix=/usr/local -Dsitelib=/usr/local/lib/site_perl -Dlibpth=/usr/local/lib /sw/lib /opt/local/lib /usr/lib -Dnetdb_host_type=const char * -Dnetdb_hlen_type=socklen_t -Uinstallusrbinperl'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-I/sw/include -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/opt/local/include',
    optimize='-O3',
    cppflags='-no-cpp-precomp -I/sw/include -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/opt/local/include'
    ccversion='', gccversion='4.0.1 (Apple Computer, Inc. build 5363)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    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/sw/lib -L/usr/local/lib -L/opt/local/lib'
    libpth=/usr/local/lib /sw/lib /opt/local/lib /usr/lib
    libs=-lgdbm -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='-L/sw/lib -bundle -undefined dynamic_lookup -L/usr/local/lib -L/opt/local/lib'

Locally applied patches:
    


@INC for perl v5.8.8:
    /sw/lib/perl5
    /sw/lib/perl5/darwin
    /usr/local/perl/5.8.8/lib/darwin-thread-multi-2level
    /usr/local/perl/5.8.8/lib
    /usr/local/lib/site_perl/5.8/darwin-thread-multi-2level
    /usr/local/lib/site_perl
    /usr/local/lib/site_perl
    .


Environment for perl v5.8.8:
    DYLD_LIBRARY_PATH (unset)
    HOME=/Users/schwern
    LANG (unset)
    LANGUAGE (unset)
    LC_CTYPE=en_US.UTF-8
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/opt/local/bin:/opt/local/sbin:/sw/bin:/sw/sbin:/Users/schwern/bin:/usr/local/bin:/Users/schwern/bin:/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin
    PERL5LIB=/sw/lib/perl5:/sw/lib/perl5/darwin
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Mar 29, 2007

From @schwern

Attached is the patch.

@p5pRT
Copy link
Author

p5pRT commented Mar 29, 2007

From @schwern

base_sigdie.patch
--- lib/base.pm	2006-10-23 01:52:58.000000000 -0700
+++ lib/base.pm	2007-03-28 21:42:53.000000000 -0700
@@ -82,21 +82,30 @@
 	      unless defined ${$base.'::VERSION'};
         }
         else {
-            local $SIG{__DIE__};
-            eval "require $base";
-            # Only ignore "Can't locate" errors from our eval require.
-            # Other fatal errors (syntax etc) must be reported.
-            die if $@ && $@ !~ /^Can't locate .*? at \(eval /;
-            unless (%{"$base\::"}) {
-                require Carp;
-                Carp::croak(<<ERROR);
+            my $sigdie;
+            {
+                local $SIG{__DIE__};
+                eval "require $base";
+                $sigdie = $SIG{__DIE__};
+
+                # Only ignore "Can't locate" errors from our eval require.
+                # Other fatal errors (syntax etc) must be reported.
+                die if $@ && $@ !~ /^Can't locate .*? at \(eval /;
+                unless (%{"$base\::"}) {
+                    require Carp;
+                    Carp::croak(<<ERROR);
 Base class package "$base" is empty.
     (Perhaps you need to 'use' the module which defines that package first.)
 ERROR
 
+                }
             }
+
             ${$base.'::VERSION'} = "-1, set by base.pm"
               unless defined ${$base.'::VERSION'};
+            
+            # Make sure a global $SIG{__DIE__} makes it out of the localization
+            $SIG{__DIE__} = $sigdie if defined $sigdie;
         }
         push @{"$inheritor\::ISA"}, $base;
 
--- lib/base/t/base.t	2006-10-23 01:52:58.000000000 -0700
+++ lib/base/t/base.t	2007-03-28 21:42:47.000000000 -0700
@@ -1,7 +1,8 @@
 #!/usr/bin/perl -w
 
 use strict;
-use Test::More tests => 11;
+use Test::More tests => 13;
+use lib 't/lib';
 
 use_ok('base');
 
@@ -85,3 +86,21 @@
          'Base class empty error message');
 
 }
+
+
+# Test that a global sigdie is preserved.
+{
+    local $SIG{__DIE__};
+    {
+        package Test::HasSigDie;
+        eval q[use base 'HasSigDie'];
+    }
+
+    ::ok $SIG{__DIE__}, 'sigdie set';
+    eval {
+        die "Testing sigdie handler";
+    };
+    package HasSigDie;
+    our $Sigdie_ran;
+    ::is $Sigdie_ran, 1;
+}
--- /dev/null	2007-03-28 21:42:35.000000000 -0700
+++ t/lib/HasSigDie.pm	2007-03-28 21:01:09.000000000 -0700
@@ -0,0 +1,5 @@
+package HasSigDie;
+
+$SIG{__DIE__} = sub { $Sigdie_ran++ };
+
+1;

@p5pRT
Copy link
Author

p5pRT commented Mar 29, 2007

@schwern - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Mar 29, 2007

From @smpeters

On Wed, Mar 28, 2007 at 08​:50​:28PM -0700, Michael G Schwern wrote​:

# New Ticket Created by Michael G Schwern
# Please include the string​: [perl #42163]
# in the subject line of all future correspondence about this issue.
# <URL​: http​://rt.perl.org/rt3/Ticket/Display.html?id=42163 >

This is a bug report for perl from schwern@​pobox.com,
generated with the help of perlbug 1.35 running under perl v5.8.8.

-----------------------------------------------------------------
[Please enter your report here]

If a module sets a global $SIG{__DIE__} handler and is loaded with "use base" that $SIG{__DIE__} handler will be localized and thus not set.

This is because of this code in base.pm.

        local $SIG\{\_\_DIE\_\_\};
        eval "require $base";

aliased.pm had a similar problem and I propose a similar fix.
http​://rt.cpan.org/Public/Bug/Display.html?id=25293

Patch forthcoming.

Since you are listed as the maintainer of base on CPAN, would you be
interested in making a release? If not, would you be willing to work
with someone to make a release?

Steve Peters
steve@​fisharerojo.org

@p5pRT
Copy link
Author

p5pRT commented Mar 29, 2007

From @schwern

Steve Peters via RT wrote​:

Since you are listed as the maintainer of base on CPAN, would you be
interested in making a release? If not, would you be willing to work
with someone to make a release?

I'm not particularly interested in maintaining that module anymore and would
be happy to hand it off to somebody.

@p5pRT
Copy link
Author

p5pRT commented Mar 30, 2007

From @rgarcia

On 29/03/07, Michael G Schwern <schwern@​pobox.com> wrote​:

I'm not particularly interested in maintaining that module anymore and would
be happy to hand it off to somebody.

I could do it, if you give me the rights on pause.

@p5pRT
Copy link
Author

p5pRT commented Mar 30, 2007

From @schwern

Rafael Garcia-Suarez wrote​:

On 29/03/07, Michael G Schwern <schwern@​pobox.com> wrote​:

I'm not particularly interested in maintaining that module anymore and
would
be happy to hand it off to somebody.

I could do it, if you give me the rights on pause.

Done, but only for base. Ilya has primary maintenance of fields which ships
in the base distribution. Ilya?

@p5pRT
Copy link
Author

p5pRT commented Mar 30, 2007

From nospam-abuse@ilyaz.org

On Fri, Mar 30, 2007 at 03​:26​:35AM -0700, Michael G Schwern wrote​:

Rafael Garcia-Suarez wrote​:

On 29/03/07, Michael G Schwern <schwern@​pobox.com> wrote​:

I'm not particularly interested in maintaining that module anymore and
would
be happy to hand it off to somebody.

I could do it, if you give me the rights on pause.

Done, but only for base. Ilya has primary maintenance of fields which ships
in the base distribution. Ilya?

Looks like a misprint. I have never used fields, so I doubt I
maintain it. ;-)

Yours,
Ilya

@p5pRT
Copy link
Author

p5pRT commented Mar 30, 2007

From @andk

On Fri, 30 Mar 2007 04​:19​:58 -0700, Ilya Zakharevich <nospam-abuse@​ilyaz.org> said​:

Done, but only for base. Ilya has primary maintenance of fields which ships
in the base distribution. Ilya?

  > Looks like a misprint. I have never used fields, so I doubt I
  > maintain it. ;-)

I seem to recall that this was a consequence of one of your OS2
packages for some reason. Nonsense corrected, now PAUSE

  "Made RGARCIA primary maintainer of fields."

--
andreas

@p5pRT
Copy link
Author

p5pRT commented Mar 30, 2007

From @rgarcia

On 30/03/07, Andreas J. Koenig <andreas.koenig.7os6VVqR@​franz.ak.mind.de> wrote​:

I seem to recall that this was a consequence of one of your OS2
packages for some reason. Nonsense corrected, now PAUSE

"Made RGARCIA primary maintainer of fields\."

Thanks. I'll upload a new version before the next stable perl :)

@p5pRT
Copy link
Author

p5pRT commented May 7, 2007

From @rgs

This problem has been fixed in bleadperl by change #31163.

@p5pRT
Copy link
Author

p5pRT commented May 7, 2007

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

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

No branches or pull requests

1 participant