From owner-freebsd-python@freebsd.org  Fri Dec 21 16:52:45 2018
Return-Path: <owner-freebsd-python@freebsd.org>
Delivered-To: freebsd-python@mailman.ysv.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1])
 by mailman.ysv.freebsd.org (Postfix) with ESMTP id 427901350195
 for <freebsd-python@mailman.ysv.freebsd.org>;
 Fri, 21 Dec 2018 16:52:45 +0000 (UTC)
 (envelope-from bugzilla-noreply@freebsd.org)
Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org
 [IPv6:2001:1900:2254:206a::50:5])
 by mx1.freebsd.org (Postfix) with ESMTP id D08CE729B9
 for <freebsd-python@freebsd.org>; Fri, 21 Dec 2018 16:52:44 +0000 (UTC)
 (envelope-from bugzilla-noreply@freebsd.org)
Received: by mailman.ysv.freebsd.org (Postfix)
 id 942F11350192; Fri, 21 Dec 2018 16:52:44 +0000 (UTC)
Delivered-To: python@mailman.ysv.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1])
 by mailman.ysv.freebsd.org (Postfix) with ESMTP id 71AE51350191
 for <python@mailman.ysv.freebsd.org>; Fri, 21 Dec 2018 16:52:44 +0000 (UTC)
 (envelope-from bugzilla-noreply@freebsd.org)
Received: from mxrelay.ysv.freebsd.org (mxrelay.ysv.freebsd.org
 [IPv6:2001:1900:2254:206a::19:3])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 server-signature RSA-PSS (4096 bits)
 client-signature RSA-PSS (4096 bits) client-digest SHA256)
 (Client CN "mxrelay.ysv.freebsd.org",
 Issuer "Let's Encrypt Authority X3" (verified OK))
 by mx1.freebsd.org (Postfix) with ESMTPS id 10392729B4
 for <python@FreeBSD.org>; Fri, 21 Dec 2018 16:52:44 +0000 (UTC)
 (envelope-from bugzilla-noreply@freebsd.org)
Received: from kenobi.freebsd.org (kenobi.freebsd.org
 [IPv6:2001:1900:2254:206a::16:76])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (Client did not present a certificate)
 by mxrelay.ysv.freebsd.org (Postfix) with ESMTPS id 3E18E16587
 for <python@FreeBSD.org>; Fri, 21 Dec 2018 16:52:43 +0000 (UTC)
 (envelope-from bugzilla-noreply@freebsd.org)
Received: from kenobi.freebsd.org ([127.0.1.118])
 by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id wBLGqhuI028600
 for <python@FreeBSD.org>; Fri, 21 Dec 2018 16:52:43 GMT
 (envelope-from bugzilla-noreply@freebsd.org)
Received: (from www@localhost)
 by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id wBLGqhlo028599
 for python@FreeBSD.org; Fri, 21 Dec 2018 16:52:43 GMT
 (envelope-from bugzilla-noreply@freebsd.org)
X-Authentication-Warning: kenobi.freebsd.org: www set sender to
 bugzilla-noreply@freebsd.org using -f
From: bugzilla-noreply@freebsd.org
To: python@FreeBSD.org
Subject: [Bug 221700] lang/python??: subprocess does not use closefrom, calls
 close(2) hundreds of thousands of times
Date: Fri, 21 Dec 2018 16:52:42 +0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: Ports & Packages
X-Bugzilla-Component: Individual Port(s)
X-Bugzilla-Version: Latest
X-Bugzilla-Keywords: needs-patch, performance
X-Bugzilla-Severity: Affects Many People
X-Bugzilla-Who: cem@freebsd.org
X-Bugzilla-Status: Open
X-Bugzilla-Resolution: 
X-Bugzilla-Priority: Normal
X-Bugzilla-Assigned-To: emaste@freebsd.org
X-Bugzilla-Flags: maintainer-feedback+
X-Bugzilla-Changed-Fields: 
Message-ID: <bug-221700-21822-1Y2MeMlBPp@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-221700-21822@https.bugs.freebsd.org/bugzilla/>
References: <bug-221700-21822@https.bugs.freebsd.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-BeenThere: freebsd-python@freebsd.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: FreeBSD-specific Python issues <freebsd-python.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/freebsd-python>, 
 <mailto:freebsd-python-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-python/>
List-Post: <mailto:freebsd-python@freebsd.org>
List-Help: <mailto:freebsd-python-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/freebsd-python>,
 <mailto:freebsd-python-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Fri, 21 Dec 2018 16:52:45 -0000

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D221700

--- Comment #13 from Conrad Meyer <cem@freebsd.org> ---
(In reply to Ed Maste from comment #10)
@Koobs (re: twitter), why would it not be async signal safe?

In general signal safety is more about interacting with userspace memory st=
ate
of ordinary non-signal contexts given arbitrary signal interruption.  I.e.,
classic example is stdio FILE objects, which may be locked or have corrupt,
half-modified state.  closefrom(2) is just a plain system call.

The original commit, r194262, just says:

> Note that this implementation of closefrom(2) does not make any effort to
> resolve userland races with open(2) in other threads.  As such, it is not
> multithread safe.

That is a comment on threading, not signals.  Signaled, single-threaded
programs are still single-threaded; the signal context and ordinary thread
context do not run concurrently.

And by definition, a user process cannot run code of any kind =E2=80=94 sig=
nal-handler
or ordinary =E2=80=94 while that user process is in the kernel.  So closefr=
om(2) in
signal handler cannot race with open(2) or other syscalls that create fds in
single-threaded programs.

The scenario the comment refers to is something like this:

- The program has two threads and fds 0-5 allocated.
- Concurrently, thread A and B attempt to:
  A: open() a new fd
  B: closefrom(3)
- The behavior is unpredictable and depends on which thread acquires the
fdesctable lock first.

[r194262]: https://svnweb.freebsd.org/base?view=3Drevision&revision=3D194262

--=20
You are receiving this mail because:
You are on the CC list for the bug.=