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

Signal arrival resets $@ #9019

Closed
p5pRT opened this issue Sep 4, 2007 · 22 comments
Closed

Signal arrival resets $@ #9019

p5pRT opened this issue Sep 4, 2007 · 22 comments

Comments

@p5pRT
Copy link

p5pRT commented Sep 4, 2007

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

Searchable as RT45173$

@p5pRT
Copy link
Author

p5pRT commented Sep 4, 2007

From amashanov@masterhost.ru

Signal arrival resets $@​

#! /usr/bin/perl

use strict;
use warnings;

$SIG{HUP} = sub{};

eval{
  die "Dead here";
};
print "1\n$@​\n";
# Here SIGHUP is arrived. To simlify this test we'll send HUP itself.
# Sending it from external process is the same.
kill 1, $$;
print "2\n$@​\n";

Perl Info

Flags:
    category=core
    severity=medium

Site configuration information for perl v5.8.8:

Configured by Debian Project at Tue Mar  6 01:52:23 UTC 2007.

Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
  Platform:
    osname=linux, osvers=2.6.15.7, archname=i486-linux-gnu-thread-multi
    uname='linux rothera 2.6.15.7 #1 smp sat sep 30 10:21:42 utc 2006 
i686 gnulinux '
    config_args='-Dusethreads -Duselargefiles -Dccflags=-DDEBIAN 
-Dcccdlflags=-fPIC -Darchname=i486-linux-gnu -Dprefix=/usr 
-Dprivlib=/usr/share/perl/5.8 -Darchlib=/usr/lib/perl/5.8 
-Dvendorprefix=/usr -Dvendorlib=/usr/share/perl5 
-Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/usr/local 
-Dsitelib=/usr/local/share/perl/5.8.8 
-Dsitearch=/usr/local/lib/perl/5.8.8 -Dman1dir=/usr/share/man/man1 
-Dman3dir=/usr/share/man/man3 -Dsiteman1dir=/usr/local/man/man1 
-Dsiteman3dir=/usr/local/man/man3 -Dman1ext=1 -Dman3ext=3perl 
-Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Uusesfio -Uusenm 
-Duseshrplib -Dlibperl=libperl.so.5.8.8 -Dd_dosuid -des'
    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 ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS 
-DDEBIAN -fno-strict-aliasing -pipe -I/usr/local/include 
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBIAN 
-fno-strict-aliasing -pipe -I/usr/local/include'
    ccversion='', gccversion='4.1.2 (Ubuntu 4.1.2-0ubuntu4)', 
gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', 
lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lgdbm -lgdbm_compat -ldb -ldl -lm -lpthread -lc -lcrypt
    perllibs=-ldl -lm -lpthread -lc -lcrypt
    libc=/lib/libc-2.5.so, so=so, useshrplib=true, libperl=libperl.so.5.8.8
    gnulibc_version='2.5'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:



@INC for perl v5.8.8:
    /etc/perl
    /usr/local/lib/perl/5.8.8
    /usr/local/share/perl/5.8.8
    /usr/lib/perl5
    /usr/share/perl5
    /usr/lib/perl/5.8
    /usr/share/perl/5.8
    /usr/local/lib/site_perl
    .


Environment for perl v5.8.8:
    HOME=/home/amashanov
    LANG=ru_RU.UTF-8
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
    PERL_BADLANG (unset)
    SHELL=/bin/bash


@p5pRT
Copy link
Author

p5pRT commented Nov 28, 2007

From jtobey@bierce.john-edwin-tobey.org

This is a bug report for perl from jtobey@​bierce.john-edwin-tobey.org,
generated with the help of perlbug 1.36 running under perl 5.10.0.


Signal handlers affect the value of $@​ even when they don't use eval/die.

The following program prints "Signal clobbers $@​!" I believe it should
print "OK".

$SIG{'INT'} = sub {
  $during = $@​;
};
$@​ = 'hello';
$before = $@​;
kill('INT', $$);
$after = $@​;

if ($before ne $after) {
  print("Signal clobbers \$\@​!\n");
}
elsif ($before ne $during) {
  print("Signal hides \$\@​\n");
}
else {
  print("OK\n");
}



Flags​:
  category=core
  severity=low


Site configuration information for perl 5.10.0​:

Configured by jtobey at Wed Nov 28 13​:39​:07 EST 2007.

Summary of my perl5 (revision 5 version 10 subversion 0) configuration​:
  Platform​:
  osname=linux, osvers=2.6.18-5-686, archname=i686-linux
  uname='linux bierce 2.6.18-5-686 #1 smp wed oct 3 00​:12​:50 utc 2007 i686 gnulinux '
  config_args='-des -Dprefix=/home/jtobey/perl-5.10.0-RC2'
  hint=recommended, useposix=true, d_sigaction=define
  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-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
  optimize='-O2',
  cppflags='-fno-strict-aliasing -pipe -I/usr/local/include'
  ccversion='', gccversion='4.1.2 20061115 (prerelease) (Debian 4.1.1-21)', gccosandvers=''
  intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
  ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
  alignbytes=4, prototype=define
  Linker and Libraries​:
  ld='cc', ldflags =' -L/usr/local/lib'
  libpth=/usr/local/lib /lib /usr/lib /usr/lib64
  libs=-lnsl -ldl -lm -lcrypt -lutil -lc
  perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
  libc=/lib/libc-2.3.6.so, so=so, useshrplib=false, libperl=libperl.a
  gnulibc_version='2.3.6'
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
  cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib'

Locally applied patches​:
  RC2


@​INC for perl 5.10.0​:
  /home/jtobey/perl-5.10.0-RC2/lib/5.10.0/i686-linux
  /home/jtobey/perl-5.10.0-RC2/lib/5.10.0
  /home/jtobey/perl-5.10.0-RC2/lib/site_perl/5.10.0/i686-linux
  /home/jtobey/perl-5.10.0-RC2/lib/site_perl/5.10.0
  .


Environment for perl 5.10.0​:
  HOME=/home/jtobey
  LANG=C
  LANGUAGE (unset)
  LC_ALL=C
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)
  PATH=/home/jtobey/bin​:/jtobey/local/bin​:/usr/local/bin​:/bin​:/usr/bin​:/usr/X11R6/bin​:/usr/local/sbin​:/usr/sbin​:/sbin
  PERL_BADLANG (unset)
  SHELL=bash

@p5pRT
Copy link
Author

p5pRT commented Dec 10, 2007

From jtobey@john-edwin-tobey.org

This ticket should say​:

Severity​: High
Perl Version​: 5.8.0, 5.8.4, 5.8.8, 5.10.0-RC2 & probably all in between.
Operating System​: Linux, Solaris, & probably all unixish and more.

This bug will spookily generate false positive eval results in any
program that uses eval and handles async signals (returns from handlers).

To fix this bug and restore the pre-5.8 behaviour, make
Perl_sighandler() enter scope and localise ERRSV before call_sv(), leave
scope and copy ERRSV thereafter. Then, after the special processing
that motivated the use of G_EVAL, it should test and (if true) die with
the copy, rather than ERRSV.

In other words, Perl_sighandler() needs to do the C equivalent of​:

my $err;
{ local $@​;
  eval ...;
  $err = $@​; }
...
die($err) if $err;

instead of the current​:

eval ...;
die($@​) if $@​;

By the way, unfriendly RT rejects my edits​:

  * Could not add new custom field value​: Permission Denied
  * Could not add new custom field value​: Permission Denied
  * Could not add new custom field value​: Permission Denied
  * Could not add new custom field value​: Permission Denied
  * Could not add new custom field value​: Permission Denied
  * Could not add new custom field value​: Permission Denied
  * Permission Denied

@p5pRT
Copy link
Author

p5pRT commented Dec 10, 2007

From [Unknown Contact. See original ticket]

This ticket should say​:

Severity​: High
Perl Version​: 5.8.0, 5.8.4, 5.8.8, 5.10.0-RC2 & probably all in between.
Operating System​: Linux, Solaris, & probably all unixish and more.

This bug will spookily generate false positive eval results in any
program that uses eval and handles async signals (returns from handlers).

To fix this bug and restore the pre-5.8 behaviour, make
Perl_sighandler() enter scope and localise ERRSV before call_sv(), leave
scope and copy ERRSV thereafter. Then, after the special processing
that motivated the use of G_EVAL, it should test and (if true) die with
the copy, rather than ERRSV.

In other words, Perl_sighandler() needs to do the C equivalent of​:

my $err;
{ local $@​;
  eval ...;
  $err = $@​; }
...
die($err) if $err;

instead of the current​:

eval ...;
die($@​) if $@​;

By the way, unfriendly RT rejects my edits​:

  * Could not add new custom field value​: Permission Denied
  * Could not add new custom field value​: Permission Denied
  * Could not add new custom field value​: Permission Denied
  * Could not add new custom field value​: Permission Denied
  * Could not add new custom field value​: Permission Denied
  * Could not add new custom field value​: Permission Denied
  * Permission Denied

@p5pRT
Copy link
Author

p5pRT commented Dec 11, 2007

From @jbenjore

On Dec 10, 2007 2​:50 PM, John Tobey via RT <perlbug-comment@​perl.org> wrote​:

This ticket should say​:

Severity​: High
Perl Version​: 5.8.0, 5.8.4, 5.8.8, 5.10.0-RC2 & probably all in between.
Operating System​: Linux, Solaris, & probably all unixish and more.

This bug will spookily generate false positive eval results in any
program that uses eval and handles async signals (returns from handlers).

Two things. I see nothing wrong with my results of running your
program and you aren't supposed to use $@​ as a boolean. If you do, you
risk getting false positives and negatives. $@​ cannot be used a
boolean in Perl 5 and it's a bug in your code if you use it that way.

$@​=
$before=hello
$during=
$after=

$@​ can be false after error because an eval{} happened during a ->DESTROY.
$@​ can be true after *NO* error because an a die happened during a
->DESTROY. The eval will still succeed though.
$@​ could be tied and act arbitrarily.
The value $@​ in could be an overloaded object. If coded poorly,
examining the value clobbers $@​. In fact, at work $@​ usually is a
stringification overloaded object. An earlier iteration computed "$@​"
improperly and would clobber $@​ during the compute.

In general you must always examine the result of eval{} to see if the
block succeeded. For the rare case where the eval block succeeds, one
->DESTROY fails and another ->DESTROY suceeds, the failing code can
only be detected by having a $SIG{__DIE__} handler. I hope Perl 6
fixes this mess.

Josh

@p5pRT
Copy link
Author

p5pRT commented Dec 11, 2007

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

@p5pRT
Copy link
Author

p5pRT commented Dec 11, 2007

From jtobey@john-edwin-tobey.org

On Tue Dec 11 01​:38​:04 2007, jjore wrote​:

Two things. I see nothing wrong with my results of running your
program and you aren't supposed to use $@​ as a boolean. If you do, you
risk getting false positives and negatives. $@​ cannot be used a
boolean in Perl 5 and it's a bug in your code if you use it that way.

Please refer to the example in the original bug report, not the
pseudocode illustrating Perl_sighandler​:
http​://rt.perl.org/rt3/Ticket/Display.html?id=47928

You have to meditate a little to appreciate the bug. If your program
uses asynchronous signals, then $@​ may be cleared at any time. In
particular, it is cleared if a signal is received between an eval
statement and subsequent examination of $@​.

Example​:

$SIG{ALRM} = sub { $got_ALRM = 1; };
alarm(1);
unless (eval sub { anything(); 1 }) {

  ### ALRM SIGNAL HERE CLEARS $@​

  print("error​:$@​");
}

The fix is simple but requires changes to Perl_sighandler() in mg.c.

By the way, though it's irrelevant to the bug, several places in the
official documentation use $@​ as a boolean. Several places in the
interpreter do the same as SvTRUE(ERRSV).

Regards,
John

@p5pRT
Copy link
Author

p5pRT commented Dec 12, 2007

From @jbenjore

On Dec 11, 2007 9​:00 AM, John Tobey via RT <perlbug-followup@​perl.org> wrote​:

On Tue Dec 11 01​:38​:04 2007, jjore wrote​:
By the way, though it's irrelevant to the bug, several places in the
official documentation use $@​ as a boolean. Several places in the
interpreter do the same as SvTRUE(ERRSV).

Until proven otherwise, all those places are bugs. It's true that in
general $@​ works fine as a boolean but perl isn't so straightforward
that you can /always/ use it.

Josh

@p5pRT
Copy link
Author

p5pRT commented Jul 1, 2009

From root@mail.nethype.de

Created by root@mail.nethype.de

$@​ is being cleared by signal handlers​:

  perl -e '$SIG{INT}=sub{}; $@​=5;kill INT =&gt; 0; die $@​'

should give me 5, but "gives" me undef.

this means that it is virtually impossible to use signal handlers for
profiling or asynchronous messaging, as almost no perl code will block
signals between e.g. eval and checking for $@​ (and I think no perl code
should have to do that).

There also seems to be no way to preserve $@​ from perl as well.

I think perl should preserve $@​, at least as long as the signal handler
does not die itself.

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl 5.10.0:

Configured by Marc Lehmann at Sat Feb 21 02:30:27 CET 2009.

Summary of my perl5 (revision 5 version 10 subversion 0) configuration:
  Platform:
    osname=linux, osvers=2.6.24-etchnhalf.1-amd64, archname=amd64-linux
    uname='linux cerebro 2.6.24-etchnhalf.1-amd64 #1 smp mon jul 21 10:36:02 utc 2008 x86_64 gnulinux '
    config_args='-Duselargefiles -Dxxxxuse64bitint -Uuse64bitall -Dusemymalloc=n -Dcc=gcc -Dccflags=-ggdb -gdwarf-2 -g3 -Dcppflags=-DPERL_ARENA_SIZE=16368 -D_GNU_SOURCE -I/opt/include -Doptimize=-O6 -msse2 -funroll-loops -fno-strict-aliasing -Dcccdlflags=-fPIC -Dldflags=-L/opt/perl/lib -L/opt/lib -Dlibs=-ldl -lm -lcrypt -Darchname=amd64-linux -Dprefix=/opt/perl -Dprivlib=/opt/perl/lib/perl5 -Darchlib=/opt/perl/lib/perl5 -Dvendorprefix=/opt/perl -Dvendorlib=/opt/perl/lib/perl5 -Dvendorarch=/opt/perl/lib/perl5 -Dsiteprefix=/opt/perl -Dsitelib=/opt/perl/lib/perl5 -Dsitearch=/opt/perl/lib/perl5 -Dsitebin=/opt/perl/bin -Dman1dir=/opt/perl/man/man1 -Dman3dir=/opt/perl/man/man3 -Dsiteman1dir=/opt/perl/man/man1 -Dsiteman3dir=/opt/perl/man/man3 -Dman1ext=1 -Dman3ext=3 -Dpager=/usr/bin/less -Uafs -Uusesfio -Uusenm -Uuseshrplib -Dd_dosuid -Dusethreads=undef -Duse5005threads=undef -Duseithreads=undef -Dusemultiplicity=undef -Demail=perl-binary@plan9.de -Dcf_email=perl-binary@plan9.de -Dcf_by=Marc Lehmann -Dlocincpth=/opt/perl/include /opt/include -Dmyhostname=localhost -Dmultiarch=undef -Dbin=/opt/perl/bin -Dxxxusedevel -DxxxDEBUGGING -Dxxxuse_debugging_perl -Dxxxuse_debugmalloc -des'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags ='-ggdb -gdwarf-2 -g3 -fno-strict-aliasing -pipe -I/opt/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O6 -msse2 -funroll-loops -fno-strict-aliasing',
    cppflags='-DPERL_ARENA_SIZE=16368 -D_GNU_SOURCE -I/opt/include -ggdb -gdwarf-2 -g3 -fno-strict-aliasing -pipe -I/opt/include'
    ccversion='', gccversion='4.3.2', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags ='-L/opt/perl/lib -L/opt/lib -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib /lib64 /usr/lib64
    libs=-ldl -lm -lcrypt
    perllibs=-ldl -lm -lcrypt
    libc=/lib/libc-2.7.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.7'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O6 -msse2 -funroll-loops -fno-strict-aliasing -L/opt/perl/lib -L/opt/lib -L/usr/local/lib'

Locally applied patches:
    http://public.activestate.com/cgi-bin/perlbrowse/p/34209
    http://public.activestate.com/cgi-bin/perlbrowse/p/34507
    http://www.gossamer-threads.com/lists/perl/porters/232549
    embed.fnc:Perl_vcroak NULLOK


@INC for perl 5.10.0:
    /root/src/sex
    /opt/perl/lib/perl5
    /opt/perl/lib/perl5
    /opt/perl/lib/perl5
    /opt/perl/lib/perl5
    /opt/perl/lib/perl5
    .


Environment for perl 5.10.0:
    HOME=/root
    LANG (unset)
    LANGUAGE (unset)
    LC_CTYPE=en_US.UTF-8
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/root/s2:/root/s:/opt/bin:/opt/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11/bin:/usr/games:/usr/local/bin:/usr/local/sbin:/root/pserv:.
    PERL5LIB=/root/src/sex
    PERL5_CPANPLUS_CONFIG=/root/.cpanplus/config
    PERLDB_OPTS=ornaments=0
    PERL_ANYEVENT_DBI_TESTS=1
    PERL_ANYEVENT_EDNS0=1
    PERL_ANYEVENT_NET_TESTS=1
    PERL_ANYEVENT_PROTOCOLS=ipv4,ipv6
    PERL_ANYEVENT_STRICT=1
    PERL_BADLANG (unset)
    PERL_UNICODE=0
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Jul 25, 2009

From p5p@spam.wizbit.be

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

$@​ is being cleared by signal handlers​:

perl -e '$SIG{INT}=sub{}; $@​=5;kill INT =&gt; 0; die $@​'

should give me 5, but "gives" me undef.

this means that it is virtually impossible to use signal handlers for
profiling or asynchronous messaging, as almost no perl code will
block
signals between e.g. eval and checking for $@​ (and I think no perl
code
should have to do that).

There also seems to be no way to preserve $@​ from perl as well.

I think perl should preserve $@​, at least as long as the signal
handler
does not die itself.

[Please do not change anything below this line]
-----------------------------------------------------------------

Binary search​:

----Program----
#!/usr/bin/perl -l

$SIG{INT}=sub{};
$@​=5;
kill INT => $$;
print defined $@​ ? $@​ : "undef";

----Output of ...l/pZGlxCF/perl-5.7.0@​8405/bin/perl----
5

----EOF ($?='0')----
----Output of ...l/pNJ3BPl/perl-5.7.0@​8409/bin/perl----

----EOF ($?='0')----
Need a perl between 8405 and 8409
No patch available between 8405 and 8409

http​://perl5.git.perl.org/perl.git/commit/
645f760
Integrate perlio​:author Jarkko Hietaniemi <jhi@​iki.fi>
  Fri, 12 Jan 2001 05​:41​:28 +0000 (05​:41 +0000)
committer Jarkko Hietaniemi <jhi@​iki.fi>
  Fri, 12 Jan 2001 05​:41​:28 +0000 (05​:41 +0000)
commit 645f760
tree 71c4b24c2565df95fd48d130423254d2ed6f65dd tree | snapshot
parent 075a4a2 commit | diff
parent e86d18f commit | diff

Integrate perlio​:

[ 8408]
Remove variables that were used in experiments.

[ 8407]
Catch die in %SIG handler and unblock the signal before re-dying.
This make Linux work _without_ sigsetjmp().
Turn off sigsetjmp() to see what else it does.
May need Configure probe for sigprocmask() if anything has sigaction()
but not sigprocmask().

p4raw-link​: @​8408 on //depot/perlio​:
e86d18f
p4raw-link​: @​8407 on //depot/perlio​:
1b26641

p4raw-id​: //depot/perl@​8409

http​://perl5.git.perl.org/perl.git/commit/
1b26641
author Nick Ing-Simmons <nik@​tiuk.ti.com>
  Thu, 11 Jan 2001 20​:57​:44 +0000 (20​:57 +0000)
committer Nick Ing-Simmons <nik@​tiuk.ti.com>
  Thu, 11 Jan 2001 20​:57​:44 +0000 (20​:57 +0000)
commit 1b26641
tree 0b4195c790a9a539f53fff4d87708a91de9c5e1d tree | snapshot
parent 4bfee16 commit | diff

Catch die in %SIG handler and unblock the signal before re-dying.
This make Linux work _without_ sigsetjmp().
Turn off sigsetjmp() to see what else it does.
May need Configure probe for sigprocmask() if anything has sigaction()
but not sigprocmask().

p4raw-id​: //depot/perlio@​8407

@p5pRT
Copy link
Author

p5pRT commented Jul 25, 2009

From [Unknown Contact. See original ticket]

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

$@​ is being cleared by signal handlers​:

perl -e '$SIG{INT}=sub{}; $@​=5;kill INT =&gt; 0; die $@​'

should give me 5, but "gives" me undef.

this means that it is virtually impossible to use signal handlers for
profiling or asynchronous messaging, as almost no perl code will
block
signals between e.g. eval and checking for $@​ (and I think no perl
code
should have to do that).

There also seems to be no way to preserve $@​ from perl as well.

I think perl should preserve $@​, at least as long as the signal
handler
does not die itself.

[Please do not change anything below this line]
-----------------------------------------------------------------

Binary search​:

----Program----
#!/usr/bin/perl -l

$SIG{INT}=sub{};
$@​=5;
kill INT => $$;
print defined $@​ ? $@​ : "undef";

----Output of ...l/pZGlxCF/perl-5.7.0@​8405/bin/perl----
5

----EOF ($?='0')----
----Output of ...l/pNJ3BPl/perl-5.7.0@​8409/bin/perl----

----EOF ($?='0')----
Need a perl between 8405 and 8409
No patch available between 8405 and 8409

http​://perl5.git.perl.org/perl.git/commit/
645f760
Integrate perlio​:author Jarkko Hietaniemi <jhi@​iki.fi>
  Fri, 12 Jan 2001 05​:41​:28 +0000 (05​:41 +0000)
committer Jarkko Hietaniemi <jhi@​iki.fi>
  Fri, 12 Jan 2001 05​:41​:28 +0000 (05​:41 +0000)
commit 645f760
tree 71c4b24c2565df95fd48d130423254d2ed6f65dd tree | snapshot
parent 075a4a2 commit | diff
parent e86d18f commit | diff

Integrate perlio​:

[ 8408]
Remove variables that were used in experiments.

[ 8407]
Catch die in %SIG handler and unblock the signal before re-dying.
This make Linux work _without_ sigsetjmp().
Turn off sigsetjmp() to see what else it does.
May need Configure probe for sigprocmask() if anything has sigaction()
but not sigprocmask().

p4raw-link​: @​8408 on //depot/perlio​:
e86d18f
p4raw-link​: @​8407 on //depot/perlio​:
1b26641

p4raw-id​: //depot/perl@​8409

http​://perl5.git.perl.org/perl.git/commit/
1b26641
author Nick Ing-Simmons <nik@​tiuk.ti.com>
  Thu, 11 Jan 2001 20​:57​:44 +0000 (20​:57 +0000)
committer Nick Ing-Simmons <nik@​tiuk.ti.com>
  Thu, 11 Jan 2001 20​:57​:44 +0000 (20​:57 +0000)
commit 1b26641
tree 0b4195c790a9a539f53fff4d87708a91de9c5e1d tree | snapshot
parent 4bfee16 commit | diff

Catch die in %SIG handler and unblock the signal before re-dying.
This make Linux work _without_ sigsetjmp().
Turn off sigsetjmp() to see what else it does.
May need Configure probe for sigprocmask() if anything has sigaction()
but not sigprocmask().

p4raw-id​: //depot/perlio@​8407

@p5pRT
Copy link
Author

p5pRT commented Jul 25, 2009

p5p@spam.wizbit.be - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jun 24, 2012

From @doy

Fixed in 100c03a.

@p5pRT
Copy link
Author

p5pRT commented Jun 24, 2012

From [Unknown Contact. See original ticket]

Fixed in 100c03a.

@p5pRT
Copy link
Author

p5pRT commented Jun 24, 2012

@doy - Status changed from 'new' to 'resolved'

@p5pRT p5pRT closed this as completed Jun 24, 2012
@p5pRT
Copy link
Author

p5pRT commented Jun 21, 2013

From @wolfsage

As of 5.17.6 (and current blead) this appears to work once again as
expected.

Can this be closed or would we like a bisect of what fixed it?

-- Matthew Horsfall (alh)

@p5pRT
Copy link
Author

p5pRT commented Jun 21, 2013

From [Unknown Contact. See original ticket]

As of 5.17.6 (and current blead) this appears to work once again as
expected.

Can this be closed or would we like a bisect of what fixed it?

-- Matthew Horsfall (alh)

@p5pRT
Copy link
Author

p5pRT commented Jun 21, 2013

From @wolfsage

On Fri, Jun 21, 2013 at 3​:24 PM, Matthew Horsfall via RT <
perlbug-comment@​perl.org> wrote​:

As of 5.17.6 (and current blead) this appears to work once again as
expected.

Can this be closed or would we like a bisect of what fixed it?

-- Matthew Horsfall (alh)

Got my answer from a different thread. Bisecting preferred, I'll try to run
one soon.

-- Matthew Horsfall (alh)

@p5pRT
Copy link
Author

p5pRT commented Jun 21, 2013

From @nwc10

On Fri, Jun 21, 2013 at 03​:44​:13PM -0400, Matthew Horsfall (alh) wrote​:

On Fri, Jun 21, 2013 at 3​:24 PM, Matthew Horsfall via RT <
perlbug-comment@​perl.org> wrote​:

As of 5.17.6 (and current blead) this appears to work once again as
expected.

Can this be closed or would we like a bisect of what fixed it?

-- Matthew Horsfall (alh)

Got my answer from a different thread. Bisecting preferred, I'll try to run
one soon.

I'm already running one. I thought that it would be easy, but it confused me
for quite a bit. The test case needs to be something like

./perl -e '$SIG{INT}=sub{}; $@​=5;kill INT =&gt; $$; die unless $@​ == 5'

not

./perl -e '$SIG{INT}=sub{}; $@​=5;kill INT =&gt; 0; die unless $@​ == 5'

as the latter kills the process group which includes bisect-runner.pl,
which means that it fails to execute `git clean` or `git reset` before
control resumes to `git bisect`. Having worked out the cause, I *thought*
that --setpgrp should deal with that, but for some reason it doesn't.

Nicholas Clark

@p5pRT
Copy link
Author

p5pRT commented Jun 21, 2013

From @nwc10

On Fri, Jun 21, 2013 at 08​:53​:45PM +0100, Nicholas Clark wrote​:

On Fri, Jun 21, 2013 at 03​:44​:13PM -0400, Matthew Horsfall (alh) wrote​:

On Fri, Jun 21, 2013 at 3​:24 PM, Matthew Horsfall via RT <
perlbug-comment@​perl.org> wrote​:

As of 5.17.6 (and current blead) this appears to work once again as
expected.

Can this be closed or would we like a bisect of what fixed it?

-- Matthew Horsfall (alh)

Got my answer from a different thread. Bisecting preferred, I'll try to run
one soon.

I'm already running one. I thought that it would be easy, but it confused me
for quite a bit. The test case needs to be something like

./perl -e '$SIG{INT}=sub{}; $@​=5;kill INT =&gt; $$; die unless $@​ == 5'

not

./perl -e '$SIG{INT}=sub{}; $@​=5;kill INT =&gt; 0; die unless $@​ == 5'

as the latter kills the process group which includes bisect-runner.pl,
which means that it fails to execute `git clean` or `git reset` before
control resumes to `git bisect`. Having worked out the cause, I *thought*
that --setpgrp should deal with that, but for some reason it doesn't.

bisect.pl --expect-fail -e '$SIG{INT}=sub{}; $@​=5;kill INT =&gt; $$; die unless $@​ == 5'

says​:

100c03a is the first bad commit
commit 100c03a
Author​: Jesse Luehrs <doy@​tozt.net>
Date​: Sun Jun 24 01​:23​:49 2012 -0500

  don't let arriving signals reset $@​ [perl #45173]

  since signals can arrive at any point, clearing $@​ isn't a safe
  thing to do

:100644 100644 8cfee10824803ce2617d7700901d8361207cc115 14965da0a895b8fc0d611a6880efb954f2d9ee20 M mg.c
:040000 040000 63fcc6b394629083467a16e184e99f8e246e8fb2 2607310a4c89dc20e99184024f7cc6c8c81d1c3e M t
bisect run success
That took 1548 seconds

I could probably have got the answer faster by adding --target=miniperl

For these bugs which have clear concise test cases, it's a shame that we
never added them as TODO tests, as that would have altered us that we'd
accidentally fixed them, and permitted us to resolve them earlier. And
to be fair, I'm as guilty as everyone else at not making this happen.

I've merged this ticket into #45173 which I think has the side effect of
resolving it.

Again, thanks for digging into RT and finding things which we can close.

Nicholas Clark

@p5pRT
Copy link
Author

p5pRT commented Jun 21, 2013

From @nwc10

On Fri, Jun 21, 2013 at 09​:23​:04PM +0100, Nicholas Clark wrote​:

I've merged this ticket into #45173 which I think has the side effect of
resolving it.

And for the benefit of all those tickets, the bug appears to have been
introduced by this commit​:

commit 1b26641
Author​: Nick Ing-Simmons <nik@​tiuk.ti.com>
Date​: Thu Jan 11 20​:57​:44 2001 +0000

  Catch die in %SIG handler and unblock the signal before re-dying.
  This make Linux work _without_ sigsetjmp().
  Turn off sigsetjmp() to see what else it does.
  May need Configure probe for sigprocmask() if anything has sigaction()
  but not sigprocmask().
 
  p4raw-id​: //depot/perlio@​8407

:100644 100644 ca06b891fca0d1d62a40b8455af823e8ace9d82c a7566e3e9451c109f27a9599a28f1044c86c54f0 M mg.c
:100644 100644 d45bd94243ceafb0ea23356fa18147ad680cc830 0ceb6ba912900ad756645b720856a2e87c0b757f M scope.h

Nicholas Clark

@p5pRT
Copy link
Author

p5pRT commented Jun 21, 2013

From @khwilliamson

On 06/21/2013 02​:23 PM, Nicholas Clark wrote​:

For these bugs which have clear concise test cases, it's a shame that we
never added them as TODO tests, as that would have altered us that we'd
accidentally fixed them, and permitted us to resolve them earlier. And
to be fair, I'm as guilty as everyone else at not making this happen.

Me too.

But for people who are reading this and want to contribute to Perl
without changing code, this would be a very helpful thing to do.

This url
https://rt-archive.perl.org/perl5/NoAuth/perl5/List.html?Field=Type&Value=Patch

lists all the tickets that have patches, though I think it misses some.
Some of those patches are test cases, so this small list would be a good
starting place.

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