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
fork/system bug on FreeBSD #6115
Comments
From alan@pair.comCreated by alan@pair.comTo: perlbug@perl.com This is a bug report for perl from alan@pair.com, ----------------------------------------------------------------- Organization pair Networks, Inc. Environment System: FreeBSD pair.com 4.5-STABLE FreeBSD 4.5-STABLE #8: Mon Apr 15 10:23:48 EDT 2002 root@pair.com:/usr/src/sys/compile/PAIRk i386 This bug is known to happen consistently on the following FreeBSD / Perl FreeBSD 4.5-STABLE / Perl 5.8.0 (vfork enabled) The bug does not occur on the following FreeBSD / Perl combination: FreeBSD 2.2.7-STABLE / Perl 5.005_02 Description While using Perl in some newer versions of FreeBSD, if the SIGCHLD handler How-To-Repeat perl -e '$SIG{CHLD} = "IGNORE"; fork or sleep 0xbeef; system "echo chamber";' Why it happens I believe the problem lies in the use of the SA_NOCLDWAIT flag when calling #ifdef SA_NOCLDWAIT The problem is, when you set SA_NOCLDWAIT, subsequent calls to wait() (or SA_NOCLDWAIT If this bit is set when calling sigaction() for the The quick fix is to stop using SA_NOCLDWAIT when you ignore SIGCHLD. This may Below is C code which compiles and runs on FreeBSD using gcc, and which #include <signal.h> int main (void) { act.sa_handler = SIG_IGN; sigaction(SIGCHLD, &act, 0); printf("fork 2\n"); act.sa_handler = SIG_IGN; printf("fork 3\n"); printf("done\n"); return 0; Perl Info
|
From alan@pair.com(Disclaimer: This is my first patch submission. If there's a better As I described in bug [perl #18849] "fork/system bug on FreeBSD," code perl -e '$SIG{CHLD} = "IGNORE"; fork or sleep 0xbeef; system "echo chamber";' Instead of returning immediately, system()'s implicit wait4pid waits I have a few possible solutions for this problem. The first, which I prefer if no one can find any problems with it, is Here is the patch, against Perl 5.8.0's source: *** util.c.orig Wed Jun 11 12:52:49 2003 The other option is to block SIGCHLD whenever Perl does a wait() Furthermore, it would not fix the case where a Perl script sets An example of this patch, applied to 5.8.0's pp_sys.c in PP(pp_system) *** pp_sys.c.orig Wed Jun 11 11:54:00 2003 if (did_pipes) + #if defined(SA_NOCLDWAIT) && defined(__FreeBSD__) Both of these patches fix the minimal failing test case I described Thanks for listening. I appreciate constructive comments on these Alan Ferrency |
From @rgsalan wrote:
I personally prefer this first patch. |
From alan@pair.comOn Wed, 11 Jun 2003, Rafael Garcia-Suarez wrote:
I don't have easy access to machines running other OS's which have If you have another BSD, try this test: If it returns immediately, your system isn't vulnerable to the bug. Alan Ferrency |
From @jhi
Both Linux and Solaris seem to have SA_NOCLDWAIT but I get no long
In Mac OS X / Darwin I get a long sleep in about every 5th-10th attempt.
-- |
From alan@pair.com
Thanks. I didn't know which systems used SA_NOCLDWAIT and which didn't.
I had more consistently failing results when I tried this on Mac OS X. Is there a handy macro to detect "BSD" without enumerating the Thanks for the test points. Alan |
From alan@pair.comCan you see if this is in your Solaris 'man sigaction' man page? SA_NOCLDWAIT I found it in a SunOS 5.9 man page online. This is in line with what (the key here is "...until ALL the calling process's child processes Thanks, Alan On Thu, 12 Jun 2003, alan wrote:
|
From enache@rdslink.roOn Thu, Jun 12, 2003 at 06:01:02PM +0300, Jarkko Hietaniemi wrote:
$ grep -ri SA_NOCLDWAIT /usr/include notice the "not supported yet" -
From SusV3: SA_NOCLDWAIT [functions/sigaction.html] Regards, |
From @jhiOn Thu, Jun 12, 2003 at 10:37:28PM +0300, Enache Adrian wrote:
If the SA_NOCLDWAIT is not supported, setting it cannot screw things -- |
From @jhiSolaris 8 sigaction(2) says: SA_NOCLDWAIT Tru64 (5.1B) also has SA_NOCLDWAIT and: SA_NOCLDWAIT and no long sleeps with 100 repeats. Open Group's Single UNIX Specification SA_NOCLDWAIT P.S. It seems that now in all of Linux, Solaris, and Tru64 I do have -- |
From alan@pair.comThanks. Now I'm even more confused :) All of these man pages say the same thing that FreeBSD's man page In the original bug report, I sent a short C program which, in If you have Even More Time To Kill, can you see if this compiles on Thanks again, Alan Ferrency On Thu, 12 Jun 2003, Jarkko Hietaniemi wrote:
|
From @jhiOn Thu, Jun 12, 2003 at 12:57:42PM -0400, alan wrote:
That's what I'm here for :-)
Compiled and tested in: Tru64/alpha 5.1B: runs quickly to completion (1) "If SA_NOCLDWAIT is set, and sig equals SIGCHLD, child processes of (2) "SA_NOCLDWAIT If set and sig equals SIGCHLD, the system will not (3) No wait4() in IRIX, waitpid() used instead. -- |
From abe@ztreet.demon.nlOp een zonnige lentedag (Thursday 12 June 2003 15:45), schreef alan:
It looks like it's a *BSD thing (both on i386). This is OpenBSD 3.2: And this is NetBSD 1.5: Good luck, Abe I guess I otherwise would sense some sarcasm in your voice but |
From alan@pair.comOn 12 Jun 2003, Jarkko Hietaniemi wrote:
As far as I can tell from reading all the man page snippets you've I'm hesitatant to suggest removing SA_NOCLDWAIT completely, for fear Thanks, Alan Ferrency
|
From @jkeenanOn Fri Jun 13 07:04:22 2003, alan wrote:
This RT has been collecting dust for more than nine years. Are there Thank you very much. |
From @jkeenanOn Thu Sep 27 18:41:23 2012, jkeenan wrote:
Another call for BSD-knowledgeable people to look at this ticket! |
From @jkeenanOn Mon Jan 14 16:56:12 2013, jkeenan wrote:
As reported in another ticket: ##### -- On that basis, I am closing this ticket. |
@jkeenan - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#18849 (status was 'resolved')
Searchable as RT18849$
The text was updated successfully, but these errors were encountered: