You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
subprocess: child_exec() uses _Py_set_inheritable() which is not async-signal-safe #76958
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/gpshead'closed_at=<Date2018-02-06.06:52:35.951>created_at=<Date2018-02-06.01:34:02.804>labels= ['extension-modules', 'type-bug', 'library', '3.7']
title='subprocess: child_exec() uses _Py_set_inheritable() which is not async-signal-safe'updated_at=<Date2018-02-06.07:25:34.347>user='https://github.com/izbyshev'
_Py_set_inheritable() raises a Python-level exception on error and thus is not async-signal-safe, but child_exec() must use only async-signal-safe functions because it's executed between fork() and exec().
Since a non-raising version is already implemented in Python/fileutils.c for internal use (set_inheritable), I suggest to simply expose it via another public function (similar to _Py_open_noraise(), etc.).
New changeset c1e46e9 by Gregory P. Smith (Alexey Izbyshev) in branch 'master': bpo-32777: Fix _Py_set_inheritable async-safety in subprocess (GH-5560) c1e46e9
New changeset 2bb0bfa by Gregory P. Smith (Miss Islington (bot)) in branch '3.7': bpo-32777: Fix _Py_set_inheritable async-safety in subprocess (GH-5560) (GH-5562) 2bb0bfa
New changeset b90c685 by Gregory P. Smith (Miss Islington (bot)) in branch '3.6': bpo-32777: Fix _Py_set_inheritable async-safety in subprocess (GH-5560) (GH-5563) b90c685
out of curiosity, did you actually diagnose a process deadlocked due to this or was it noted via code inspection?
The latter. I noted it while working on another issue. While it was easy to trigger a malloc() in child_exec() by e.g. specifying an invalid fd in pass_fds for Popen, I haven't tried to arrange a deadlock.
Activity
izbyshev commentedon Feb 6, 2018
_Py_set_inheritable() raises a Python-level exception on error and thus is not async-signal-safe, but child_exec() must use only async-signal-safe functions because it's executed between fork() and exec().
Since a non-raising version is already implemented in Python/fileutils.c for internal use (set_inheritable), I suggest to simply expose it via another public function (similar to _Py_open_noraise(), etc.).
gpshead commentedon Feb 6, 2018
out of curiosity, did you actually diagnose a process deadlocked due to this or was it noted via code inspection?
this issue has been around since 3.4 and the file descriptor inheritance changes from the looks of things.
gpshead commentedon Feb 6, 2018
New changeset c1e46e9 by Gregory P. Smith (Alexey Izbyshev) in branch 'master':
bpo-32777: Fix _Py_set_inheritable async-safety in subprocess (GH-5560)
c1e46e9
gpshead commentedon Feb 6, 2018
New changeset 2bb0bfa by Gregory P. Smith (Miss Islington (bot)) in branch '3.7':
bpo-32777: Fix _Py_set_inheritable async-safety in subprocess (GH-5560) (GH-5562)
2bb0bfa
gpshead commentedon Feb 6, 2018
New changeset b90c685 by Gregory P. Smith (Miss Islington (bot)) in branch '3.6':
bpo-32777: Fix _Py_set_inheritable async-safety in subprocess (GH-5560) (GH-5563)
b90c685
izbyshev commentedon Feb 6, 2018
The latter. I noted it while working on another issue. While it was easy to trigger a malloc() in child_exec() by e.g. specifying an invalid fd in pass_fds for Popen, I haven't tried to arrange a deadlock.