Skip to content

Error message "Signal SIGCHLD received, but no signal handler set." #17662

Open
@gflohr

Description

@gflohr

Module:

Description

In a web server based on Net::Server (version 2.007 and the most recent 2.009) with the Net::Server::Single personality, I get the error "Signal SIGCHLD received, but no signal handler set." and the server terminates. When using the Net::Server::PreFork personality, the signal is SIGHUP instead of SIGCHLD, and the server continues to run because only one of the forked children had terminated.

The error occurs after a handler of the server has forked a background process. In the child, POSIX::setsid() is called, all open file descriptors are closed and STDIN is redirected to /dev/null. STDOUT and STDERR are not re-opened because the same code is supposed to work in a mod_perl environment. %SIG is not modified. The child process (another Perl script) is executed with exec().

There is a corresponding question on stackoverflow.com: https://stackoverflow.com/questions/60708194/error-message-signal-sigchld-received-but-no-signal-handler-set/60761593#60761593

I have answered it myself with additional findings/information: https://stackoverflow.com/a/60761593/5464233

My workaround is to explicitely assign "DEFAULT" to $SIG{CHLD} resp. $SIG{HUP}, instead of the old value undef but that is not a satisfying solution. That is very similar to the workaround that was recommended for an almost identical problem in GNU parallel several years ago: https://lists.gnu.org/archive/html/bug-parallel/2016-10/msg00000.html

Steps to Reproduce

Not possible. It's a (proprietary) application with 350000+ lines of Perl code. Modifying the code or running the application in the Perl debugger makes the error disappear instantly. If there is interest in trying to debug the problem, I can provide access to a test installation.

I also wasn't able to run the program in gdb because the server did not come up.

Expected behavior

The script should not be able to make the interpreter terminate prematurely.

Perl configuration

# perl -V output goes here (a little below ...)

I have tested on Mac OS X with these Perl versions using perlbrew:

$ perlbrew list
  perl-5.30.2                               
* perl-5.28.0                               
  perl-5.26.2                               
  perl-5.26.0                               
  perl-5.18.4                               
  perl-5.16.3                               
  perl-5.14.4                               
  perl-5.8.9                                

All versions starting from 5.18.4 have the problem. The older ones do not have it.

The same behavior was reported for 5.26.x to 5.30.x on Linux.

 $ perl -V
Summary of my perl5 (revision 5 version 28 subversion 0) configuration:
   
  Platform:
    osname=darwin
    osvers=18.0.0
    archname=darwin-2level
    uname='darwin hostname.example.com 18.0.0 darwin kernel version 18.0.0: wed aug 22 20:13:40 pdt 2018; root:xnu-4903.201.2~1release_x86_64 x86_64 '
    config_args='-de -Dprefix=/Users/myname/perl5/perlbrew/perls/perl-5.28.0 -Aeval:scriptdir=/Users/myname/perl5/perlbrew/perls/perl-5.28.0/bin'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=undef
    usemultiplicity=undef
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
    bincompat5005=undef
  Compiler:
    cc='cc'
    ccflags ='-fno-common -DPERL_DARWIN -mmacosx-version-min=10.14 -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -I/opt/local/include -DPERL_USE_SAFE_PUTENV'
    optimize='-O3'
    cppflags='-fno-common -DPERL_DARWIN -mmacosx-version-min=10.14 -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -I/opt/local/include'
    ccversion=''
    gccversion='4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.5)'
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=16
    longdblkind=3
    ivtype='long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='off_t'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='cc'
    ldflags =' -mmacosx-version-min=10.14 -fstack-protector-strong -L/usr/local/lib -L/opt/local/lib'
    libpth=/usr/local/lib /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.0/lib /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/lib /opt/local/lib /usr/lib
    libs=-lpthread -lgdbm -ldbm -ldl -lm -lutil -lc
    perllibs=-lpthread -ldl -lm -lutil -lc
    libc=
    so=dylib
    useshrplib=false
    libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=bundle
    d_dlsymun=undef
    ccdlflags=' '
    cccdlflags=' '
    lddlflags=' -mmacosx-version-min=10.14 -bundle -undefined dynamic_lookup -L/usr/local/lib -L/opt/local/lib -fstack-protector-strong'


Characteristics of this binary (from libperl): 
  Compile-time options:
    HAS_TIMES
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    PERL_USE_SAFE_PUTENV
    USE_64_BIT_ALL
    USE_64_BIT_INT
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
  Locally applied patches:
    Devel::PatchPerl 1.52
  Built under darwin
  Compiled at Nov  9 2018 16:47:19
  %ENV:
    PERLBREW_HOME="/Users/myname/.perlbrew"
    PERLBREW_MANPATH="/Users/myname/perl5/perlbrew/perls/perl-5.28.0/man"
    PERLBREW_PATH="/Users/myname/perl5/perlbrew/bin:/Users/myname/perl5/perlbrew/perls/perl-5.28.0/bin"
    PERLBREW_PERL="perl-5.28.0"
    PERLBREW_ROOT="/Users/myname/perl5/perlbrew"
    PERLBREW_SHELLRC_VERSION="0.87"
    PERLBREW_VERSION="0.87"
  @INC:
    /Users/myname/perl5/perlbrew/perls/perl-5.28.0/lib/site_perl/5.28.0/darwin-2level
    /Users/myname/perl5/perlbrew/perls/perl-5.28.0/lib/site_perl/5.28.0
    /Users/myname/perl5/perlbrew/perls/perl-5.28.0/lib/5.28.0/darwin-2level
    /Users/myname/perl5/perlbrew/perls/perl-5.28.0/lib/5.28.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions