This is the mail archive of the cygwin@cygwin.com 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]

RE: Memory Management on AMD64 in 32-bit mode


This looks like a logic error in fork.cc/dcrt0.cc to me, but I'm
probably not understanding something.

alloc_stack_hard_way assumes that the memory at ci->stacktop is
available. ci->stacktop is set to be the region of memory that contains
a stack variable in the parent process at the time that stack_base is
called.

alloc_stack_hard_way is called when the region containing the stack as
of the call to alloc_stack is at the same place as the region containing
the stack at the time that stack_base was called.

I don't exactly see how it is safe to assume that the child process will
have unused memory at the location that corresponds to the parent
process's stack region at the time that stack_base was called, but I've
only spent 1 hour on the problem. In any case, it isn't available.

A minor problem: %E always says Win32 error 0 even when GetLastError()
returns a non-zero value. In fact, VirtualAlloc is setting the last
error to what one would expect.

I assume that there's a very strong reason why this code can't just
allocate a stack any-old-place (calling VirtualAlloc with first arg 0)
and use it. What I don't understand is the nature of the constraints. If
the parent needs to know, why not have stack_base make a call to
VirtualAlloc with first arg 0 to allocate a brand-new region, on the
theory that such a region is a lot more likely to end up with a
corresponding hole in the child process?

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


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