[PATCH] [BZ #18433] Check file access/existence before forking.

Szabolcs Nagy szabolcs.nagy@arm.com
Fri Sep 18 15:32:00 GMT 2015


On 18/09/15 16:19, Alexander Monakov wrote:
> On Fri, 18 Sep 2015, Szabolcs Nagy wrote:
>
>> On 18/09/15 15:44, Carlos O'Donell wrote:
>>> Note that it is possible to use vfork in certain conditions,
>>> and we do in glibc. So one should not entirely dismiss vfork,
>>> but that's slightly off topic.
>>
>> are you sure?
>>
>> i think all use of vfork is invalid c: the compiler can
>> spill registers on the stack then in the child clobber
>> them, then after vfork returns in the parent the
>> clobbered registers are restored breaking the expectations
>> of the compiler. (this can break independently of how
>> the c code around vfork looks like).
>
> The same argument applies to setjmp, and the solution in GCC is the
> same for both: GCC internally recognizes vfork, setjmp, and a few other
> functions as functions that "return twice".
>
> (after all, if it was broken like you describe, one would expect to witness
> such breakage in practice, for instance with GNU Make prior to 4.0)
>

that's surprising: setjmp is standard c
and it is a macro so it cannot be called
through a function pointer.. this is not
true for vfork so it's not clear why gcc
recognizes it.

> Alexander
>



More information about the Libc-alpha mailing list