From welch@panasas.com  Fri Nov 27 10:02:54 2009
Return-Path: <welch@panasas.com>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id E2A241065726;
	Fri, 27 Nov 2009 10:02:54 +0000 (UTC)
	(envelope-from welch@panasas.com)
Received: from natasha.panasas.com (natasha.panasas.com [67.152.220.90])
	by mx1.freebsd.org (Postfix) with ESMTP id 853DC8FC17;
	Fri, 27 Nov 2009 10:02:54 +0000 (UTC)
Received: from medlicott.panasas.com (medlicott.panasas.com [172.17.132.188])
	by natasha.panasas.com (8.13.1/8.13.1) with ESMTP id nAR96pc0024638;
	Fri, 27 Nov 2009 04:06:51 -0500
Received: from panasas.com (localhost.localdomain [127.0.0.1])
	by medlicott.panasas.com (8.13.5/8.13.7) with ESMTP id nAR96nmJ023946;
	Fri, 27 Nov 2009 01:06:49 -0800
Message-Id: <200911270906.nAR96nmJ023946@medlicott.panasas.com>
Date: Fri, 27 Nov 2009 01:06:49 -0800
From: "Welch, Brent" <welch@panasas.com>
To: bug-followup@FreeBSD.org, phk@critter.freebsd.dk,
        simon.perreault@viagenie.ca, deischen@FreeBSD.org
Cc: welch@panasas.com
Subject: fork+exec from threaded FreeBSD 7.2 application

>Number:         140932
>Category:       kern
>Synopsis:       fork+exec from threaded FreeBSD 7.2 application
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Nov 27 10:10:00 UTC 2009
>Closed-Date:    
>Last-Modified:  Sat May 15 21:03:52 UTC 2010
>Originator:     
>Release:        
>Organization:
>Environment:
>Description:
 Regarding bug 101323, we're seeing either crashes or hangs,
 on occasion, when our multi-threaded process nanny does a
 fork+exec sequence.  We are using FreeBSD 7.2 and libthr
 
 We are super careful with signal masks,
 and do the bare minimum between fork and exec.  However, due
 to various libraries that we use, we have a bunch of threads
 running in the main process.  We've been using this code 
 on 4.6.2 and uniprocessors for years w/out issue.
 We are using 7.2 on 64-bit multi-core platforms. We do:
 
         m_pid = fork();
         if (m_pid == 0 {
            /* pseudo code */
            fstat() and close() file descriptors 3 and above
            setuid() if necessary
            restore signal masks
            setpgid()
            creat() a log file and dup to stdout and stderr
            execve()
         }
 
 Is this approach doomed to failure, or should we be able to get
 this working?  It doesn't look like Daniel's patch is in our
 libthr/thread/thr_fork.c
 So, I can do the obvious and try that.  I'm curious about just
 running __sys_fork() instead, however, as the process is
 going to obliterate itself with execve() anyway.
 
 --
 Brent Welch
 Director, Software Architecture, Panasas Inc
 The Leader in Parallel Storage
 
 www.panasas.com
 welch@panasas.com
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: gnats-admin->freebsd-bugs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Fri Nov 27 10:15:00 UTC 2009 
Responsible-Changed-Why:  
Rescue from 'pending'. 

To submitter: did you intend to have this tracked as a followup 
to kern/101323, or do you want it as a separate PR? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=140932 
State-Changed-From-To: open->feedback 
State-Changed-By: linimon 
State-Changed-When: Tue Dec 22 09:28:47 UTC 2009 
State-Changed-Why:  
Note that submitter was asked for feedback. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=140932 

From: "Welch, Brent" <welch@panasas.com>
To: bug-followup@FreeBSD.org, welch@panasas.com
Cc:  
Subject: Re: kern/140932: fork+exec from threaded FreeBSD 7.2 application
Date: Mon, 04 Jan 2010 12:12:45 -0800

 Let's leave this as its own case.  I still need to confirm the
 effectiveness of the other patch.  I may also choose to use an
 unwrapped sysfork().
  
 --
 Brent Welch
 Director, Software Architecture, Panasas Inc
 The Leader in Parallel Storage
 
 www.panasas.com
 welch@panasas.com
 
 
State-Changed-From-To: feedback->open 
State-Changed-By: jilles 
State-Changed-When: Sat May 15 21:02:52 UTC 2010 
State-Changed-Why:  
Feedback was received. 

To the submitter: also consider vfork() or posix_spawn(). 
More information about the crashes will also be helpful. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=140932 
>Unformatted:
