This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author gregory.p.smith
Recipients gregory.p.smith, izbyshev, socketpair
Date 2022-04-07.21:46:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1649367969.78.0.229485349626.issue47245@roundup.psfhosted.org>
In-reply-to
Content
Thanks!  I agree with you that this is probably not an actual problem on Linux.

_I did look at the various glibc architecture vfork.s implementations: Cute tricks used on some where they need to avoid a stack modifying traditional return from vfork()._

As for glibc specifics, I'm mostly thinking of the calls we do in the child.

According to the "Standard Description (POSIX.1)" calls to anything other than `_exit()` or `exec*()` are not allowed.  But the longer "Linux Description" in that vfork(2) man page does not say that.  Which implies merely by omission that calls to other things are okay so long as you understand everything they do to the process heap/stack/state.  (I wish it were *explicit* about that)

Some of the calls we do from our child_exec() code... many are likely "just" syscall shims and thus fine - but that is technically up to libc.

A few others are Py functions that go elsewhere in CPython and while they may be fine for practical reasons today with dangerous bits on conditional branches that technically should not be possible to hit given the state by the time we're at this point in _posixsubprocess, pose a future risk - anyone touching implementations of those is likely unaware of vfork'ed child limitations that must be met.

For example if one of the potential code paths that trigger an indirect Py_FatalError() is hit... that fatal exit code is definitely not post-vfork-child safe.  The pre-exec child dying via that could screw up the vfork parent process's state.
History
Date User Action Args
2022-04-07 21:46:09gregory.p.smithsetrecipients: + gregory.p.smith, socketpair, izbyshev
2022-04-07 21:46:09gregory.p.smithsetmessageid: <1649367969.78.0.229485349626.issue47245@roundup.psfhosted.org>
2022-04-07 21:46:09gregory.p.smithlinkissue47245 messages
2022-04-07 21:46:09gregory.p.smithcreate