This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: static fork strerror and how they interact.



On 21-12-2015 13:12, Carlos O'Donell wrote:
> On Sun, Dec 20, 2015 at 6:09 PM, Ãngel GonzÃlez <keisial@gmail.com> wrote:
>> On 28/10/14 15:02, Carlos O'Donell wrote:
>>>
>>> Even more complicated is using vfork safely from a multi-threaded
>>> application. I have written up a very thorough example on this, but
>>> have not posted it yet.
>>
>> Did you finally publish this?
> 
> Yes.
> 
> You can read it here:
> http://developerblog.redhat.com/2015/08/19/launching-helper-process-under-memory-and-latency-constraints-pthread_create-and-vfork/
> 

So it is basically a strip down posix_spawn implementation without the file
actions or spawn attributes implemented with vfork.  IMHO I think we can 
fix GLIBC posix_spawn issues [1] [2] [3] [4] so there will be no need for 
such reimplementation and still having good performance concerned memory
and latency constraints.

My understanding reading the bugzillas reports the fork use in current
GLIBC code for cases where file actions are required are due the fact
they are cancellation entrypoint and since vfork share the VMA it would
be simpler to just use fork to avoid the cancellation action.  I see
it can be fixed by setting disabling cancellation on function execution
for the current thread and on child by using direct syscall invocation
or by creating the syscall_no_cancel wrappers.

Also, as pointed out by Rich Felker, instead of vfork() it would be
preferable use clone with CLONE_VM. It has some advantages:

1. The compiler could make optimization in the child function that
   might clobber parent's local variable (as pointed out in the
   first comment in your blog entry).

2. With strace there might be cases where it allows the vforking 
   parent to run before the child execs

Also with a simple ipc mechanism (close-on-exec pipe) it is possible
to report exec failures to the posix_spawn caller instead of just
reporting the status 127 on exec error.

This is on my radar list.

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=14499
[2] https://sourceware.org/bugzilla/show_bug.cgi?id=14749
[3] https://sourceware.org/bugzilla/show_bug.cgi?id=14750
[4] https://sourceware.org/bugzilla/show_bug.cgi?id=10354

> Cheers,
> Carlos.
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]