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

perl hangs if CLONE_SKIP dies #10177

Open
p5pRT opened this issue Feb 14, 2010 · 3 comments
Open

perl hangs if CLONE_SKIP dies #10177

p5pRT opened this issue Feb 14, 2010 · 3 comments

Comments

@p5pRT
Copy link

p5pRT commented Feb 14, 2010

Migrated from rt.perl.org#72808 (status was 'open')

Searchable as RT72808$

@p5pRT
Copy link
Author

p5pRT commented Feb 14, 2010

From @cpansprout

$ perl -Mthreads -le 'sub CLONE_SKIP{die} create threads sub{ }=>->join'
Died at -e line 1.
<hangs>

If CLONE_SKIP dies, threads.pm does not have a chance to unlock the
appropriate mutexes. So perl hangs on exit (or the next attempt to
start a thread), ignoring all signals.

Use of uninitialized value $category in concatenation (.) or string
at /usr/local/bin/perlbug5.11.4 line 645.
Use of uninitialized value $severity in concatenation (.) or string
at /usr/local/bin/perlbug5.11.4 line 645.


Flags​:
  category=library
  severity=medium


Site configuration information for perl 5.11.4​:

Configured by sprout at Thu Feb 4 18​:03​:57 PST 2010.

Summary of my perl5 (revision 5 version 11 subversion 4 patch
v5.11.4-50-g23d7219) configuration​:
  Snapshot of​: 23d7219
  Platform​:
  osname=darwin, osvers=10.0.0, archname=darwin-thread-multi-2level
  uname='darwin pint.local 10.0.0 darwin kernel version 10.0.0​: fri
jul 31 22​:47​:34 pdt 2009; root​:xnu-1456.1.25~1release_i386 i386 '
  config_args='-de -Dusedevel -Dprefix=/opt/testing123'
  hint=previous, useposix=true, d_sigaction=define
  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 ='-fno-common -DPERL_DARWIN -no-cpp-precomp -fno-
strict-aliasing -pipe -fstack-protector -I/usr/local/include',
  optimize='-O3',
  cppflags='-no-cpp-precomp -fno-common -DPERL_DARWIN -no-cpp-
precomp -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/
include -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing
-pipe -fstack-protector -I/usr/local/include'
  ccversion='', gccversion='4.2.1 (Apple Inc. build 5646)',
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 =' -fstack-
protector -L/usr/local/lib'
  libpth=/usr/local/lib /usr/lib
  libs=-ldbm -ldl -lm -lutil -lc
  perllibs=-ldl -lm -lutil -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 -fstack-protector'

Locally applied patches​:


@​INC for perl 5.11.4​:
  /usr/local/lib/perl5/site_perl/5.11.4/darwin-thread-multi-2level
  /usr/local/lib/perl5/site_perl/5.11.4
  /usr/local/lib/perl5/5.11.4/darwin-thread-multi-2level
  /usr/local/lib/perl5/5.11.4
  /usr/local/lib/perl5/site_perl
  .


Environment for perl 5.11.4​:
  DYLD_LIBRARY_PATH (unset)
  HOME=/Users/sprout
  LANG=en_US.UTF-8
  LANGUAGE (unset)
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)
  PATH=/usr/bin​:/bin​:/usr/sbin​:/sbin​:/usr/local/bin​:/usr/X11/bin​:/
usr/local/bin
  PERL_BADLANG (unset)
  SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Feb 16, 2010

From @jdhedden

$ perl -Mthreads -le 'sub CLONE_SKIP{die} create threads sub{ }=>->join'
Died at -e line 1.
<hangs>

If CLONE_SKIP dies, threads.pm does not have a chance to unlock the
appropriate mutexes. So perl hangs on exit (or the next attempt to
start a thread), ignoring all signals.

With bleadperl under Cygwin on Windows, the above produces​:

perl -Mthreads -le 'sub CLONE_SKIP{die} create threads sub{ }=>->join'
Died at -e line 1.
panic​: MUTEX_LOCK (45) [threads.xs​:319] at -e line 1.

The offending line is in S_exit_warning() in threads.xs
where it tries to lock the mutex​:

  MUTEX_LOCK(&MY_POOL.create_destruct_mutex);

The path of execution looks to be that first
ithread_create() in threads.xs is called where the above
mutex is locked, then S_ithread_create() is called followed
by a call to perl_clone() during which CLONE_SKIP() and the
subsequent die() are executed. Since CLONE_SKIP() is called
in the main thread's context, the die() triggers the exiting
of the app which eventually leads to a call to
S_exit_warning() in threads.xs with the mutex still locked,
hence causing the panic.

I not knowledgable enough to effect a solution.

One possible kludge for this would be to disallow die()
inside CLONE_SKIP(), and to document as such in perlmod.pod.
To handle the die() call, CLONE_SKIP should be called in a
G_EVAL, and a warning should be output if ERRSV is set.

If the above is acceptable, I think I can generate a patch to
accomplish it.

@p5pRT
Copy link
Author

p5pRT commented Feb 16, 2010

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

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

2 participants