[issue47245] Subprocess with vfork() is broken

2022-04-06 Thread Марк Коренберг

Марк Коренберг  added the comment:

Solution:

https://github.com/bminor/glibc/blob/master/sysdeps/unix/sysv/linux/spawni.c#L309

In short - do not use vfork(). Use clone(CLONE_VM | CLONE_VFORK). and do 
something with stack.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue47245] Subprocess with vfork() is broken

2022-04-06 Thread Марк Коренберг

Марк Коренберг  added the comment:

https://github.com/python/cpython/blob/4a08c4c469d36f99d3a5e0f17ad82ab35dcf2835/Modules/_posixsubprocess.c#L717

child_exec(exec_array, argv, envp, cwd,
   p2cread, p2cwrite, c2pread, c2pwrite,
   errread, errwrite, errpipe_read, errpipe_write,
   close_fds, restore_signals, call_setsid,
   call_setgid, gid, call_setgroups, groups_size, groups,
   call_setuid, uid, child_umask, child_sigmask,
   py_fds_to_keep, preexec_fn, preexec_fn_args_tuple);



Py_NO_INLINE static void
child_exec(char *const exec_array[],
   char *const argv[],
   char *const envp[],
   const char *cwd,
   int p2cread, int p2cwrite,
   int c2pread, int c2pwrite,


-

So, calling child_exec pushes to stack GUARANTEED. This is the bug. In fact 
everything works, but is too weak and break at any moment.

Again. Please comment calling vfork() for now. And re-implement child part 
later.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue47245] Subprocess with vfork() is broken

2022-04-06 Thread Марк Коренберг

Марк Коренберг  added the comment:

Rewriting in a way that guarantee no stack (and heap) usage. Because stack is 
shared between child and parent. It seems there is no crossplatform way. 
Happily we can use some code like I wrote by link in the first message. OR, 
stick to posix_nspawn which is cross-platform.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue47245] Subprocess with vfork() is broken

2022-04-06 Thread Марк Коренберг

New submission from Марк Коренберг :

Using vfork in #35823 is VERY tricky. Please comment out vfork() usage for now. 
Yes, we can (should) use vfork(), but we have to rewrite the child code.

https://bugzilla.kernel.org/show_bug.cgi?id=215813

I would say it's URGENT.

--
components: Extension Modules
messages: 416897
nosy: socketpair
priority: normal
severity: normal
status: open
title: Subprocess with vfork() is broken
versions: Python 3.10, Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com