Title: Disallow fork in a subinterpreter.
Type: Stage: resolved
Components: Interpreter Core Versions: Python 3.8
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: eric.snow Nosy List: eric.snow, gregory.p.smith
Priority: normal Keywords: patch

Created on 2018-09-12 21:04 by eric.snow, last changed 2018-09-14 21:18 by eric.snow. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 9279 merged eric.snow, 2018-09-13 19:21
Messages (3)
msg325181 - (view) Author: Eric Snow (eric.snow) * (Python committer) Date: 2018-09-12 21:04
os.fork() potentially has some problematic behavior when called from a subinterpreter.  In additional to the normal fork+threads madness, there's the question of what to do with existing subinterpreters.  The simplest solution is to simply disallow fork in a subinterpreter and then wipe out all subinterpreters in the child process post-fork (if os.fork() called in the main interpreter).
msg325302 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2018-09-13 23:05
+1 agreed.  this is the simplest approach to start with.

Code to restrict: os.fork itself and disallowing the use of preexec_fn on subprocess within subinterpreters.

feel free to ignore preexec_fn in subprocess for the time being if desired, we already promise people that it is a bad idea legacy API that we don't want, guaranteed to cause undiagnosable problems and deadlocks at times. :)
msg325400 - (view) Author: Eric Snow (eric.snow) * (Python committer) Date: 2018-09-14 21:17
New changeset 5903296045b586b9cd1fce0b1e02caf896028d1d by Eric Snow in branch 'master':
bpo-34651: Only allow the main interpreter to fork. (gh-9279)
Date User Action Args
2018-09-14 21:18:10eric.snowsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-09-14 21:17:31eric.snowsetmessages: + msg325400
2018-09-13 23:05:46gregory.p.smithsetmessages: + msg325302
2018-09-13 19:21:43eric.snowsetkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request8710
2018-09-12 21:04:23eric.snowcreate