This is the mail archive of the cygwin-developers mailing list for the Cygwin 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] |
On May 3 11:46, Ryan Johnson wrote:Wonderful. I copied the example of heap.cc in calling fork_info->handle_failure(), and it works beautifully... except when the child seg faults.Hi all,
I'm working on some changes to fork() which would detect early the case where a parent-child pair have unresolvable differences in address space layout (e.g. thread stacks, heaps, or statically-linked dlls which moved).
Detecting the problem turned out to be pretty easy, but making the child exit cleanly is not. This leads to two questions, followed by what I have figured out so far while attempting to answer them myself.
1. What's the best way to make a child process notify the parent that the fork() cannot succeed, and exit cleanly?Usually by using some helpful status code which then can be recognized by child_info::proc_retry.
I wish it was recoverable, because it's a huge pain for applications which pull in many statically-linked dlls and then fork (emacs, gcc, python, ...). Unfortunately, I know of no way to force-unload a dll brought in by the nt loader. If one of those dlls lands in the wrong place, we're stuck even if we figure out how to get rid of whatever heap/stack/file-map was in the way.Given that the cause of the fork failure is known (rather than some surprise or bug), I propose that the messages go to some strace channel (a new one for fork, perhaps?) and that the child exit without attempting to generate a dump file (especially since dumpSounds ok to me, if you're really sure that the situation is not recoverable.
I'll keep that in mind, but for now I'm leaving it alone. Technically it's always possible the fork could succeed, and I don't know how effectively I could identify a bad parent in the general case (other than seeing that fork fails repeatedly).See above. That's handled in child_info::proc_retry.generation itself has a tendency to cause crashes). It would also be good, in cases where the parent is the reason for fork failures, to prevent Windows from respawning the process so many times (though it is admittedly handy when the child was the problem and the fork succeeds on the nth try).
I'm talking about a call to dll_list::alloc, due to a DLL_LINK which did not map to its parent's address. At this point we know the fork has failed and there's no point continuing to try.All of this still leaves the question of how to exit the child process, "properly" though. Is it necessary to wait for dll initialization to finish first, for example?I'm not sure I understand the question. How do you know which DLL is already initialized and which isn't?
Thoughts? Ryan
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |