[issue47245] potential undefined behavior with subprocess using vfork() on Linux?

Alexey Izbyshev report at bugs.python.org
Fri Apr 8 06:59:58 EDT 2022


Alexey Izbyshev <izbyshev at ispras.ru> added the comment:

> 3. We have to fix error-path in order not to change heap state (contents and allocations), possibly do not touch locks. During vfork() child execution - the only parent THREAD (not the process) is blocked. For example, it's not allowed to touch GIL. Child process may die unexpectedly and leave GIL locked. Is it possible to rewrite children path for vfork() case without any Py* calls ? As an idea, we can prepare all low-level things (all the pointers to strings and plain values) before vfork(), so child code will use only that data.

What specifically do you propose to fix? There is no problem with GIL if the child dies because the GIL is locked and unlocked only by the parent and the child never touches it. Similarly, only Py_* calls known to be safe are used. As for "pointers to strings", it's not clear to me what you mean, but if you mean allocations, they are already done before (v)fork(), since the child code is required to be async-signal-safe even if plain fork() is used.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue47245>
_______________________________________


More information about the Python-bugs-list mailing list