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, socketpair
Date 2022-04-06.22:59:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1649285956.82.0.0203648951119.issue47245@roundup.psfhosted.org>
In-reply-to
Content
Can you provide a reproducable way to demonstrate evidence of a problem in CPython's use of the Linux libc vfork() implementation?  A test case that causes a CPython parent or child process on Linux when built with HAVE_VFORK failing to function properly would help prioritize this because in practice nobody has reported problems in 3.10.

(we've deployed the subprocess vfork code into thousands production Python programs at work in the past year w/o issues being reported - though we have a constrained environment with use on only a couple of libc versions and limited set of kernels on a few very common architectures)

General thinking (possible dated and incorrect - against what https://man7.org/linux/man-pages/man2/vfork.2.html wording claims with its "or calls any other function" text):

Pushing additional data onto the stack in the child process _should_ not a problem.  That by definition lands in previously unused pre-allocated stack space.  If that page faults, that could map a new page into the process state shared by both the paused parent and running child. But this page mapping should be fine - the child exec that resumes the parent means the parent is the only one who sees it.

When the parent process resumes, sure, that data will be in that memory on the unallocated portion of stack, but critically the *stack pointer* in the parent process (a register) never changes.  As far as I understand things, registers are not shared between vfork()ed processes.  So the parent only sees some temporary data having been written to the unused region of the stack by the since-replaced by exec() child process.  No big deal.

**Untrue wishful thinking**: If a new stack were needed on a given platform for use in the vfork()ed child, I'd like it to be the job of libc to take care of that for us.  glibc sources do no such thing (every vfork supporting architecture has a vfork.S code that appears to make the syscall and jump back to the caller without stack manipulation).
History
Date User Action Args
2022-04-06 22:59:16gregory.p.smithsetrecipients: + gregory.p.smith, socketpair
2022-04-06 22:59:16gregory.p.smithsetmessageid: <1649285956.82.0.0203648951119.issue47245@roundup.psfhosted.org>
2022-04-06 22:59:16gregory.p.smithlinkissue47245 messages
2022-04-06 22:59:16gregory.p.smithcreate