This is the mail archive of the cygwin 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: Cygwin.dll crash, alloca and custom stack


On Mon, Aug 15, 2005 at 12:58:10PM +1000, Bitmead, Chris wrote:
>cgf wrote:
>>It is really not nonsensible for an OS to assume that it has control of
>>the stack.
>
>Lots of claims flying around, but no justification.  An OS specified
>stack can provide automatic extension to applications that are
>interested in that feature, but apart from that I don't see why it
>should give a rip what an app does with its stack.

The OS may care about where the stack lives and how it is laid out.
Windows allocates memory in a special way when it creates the stack to
allow automatic extension of the stack.  The runtime may also care.

Windows doesn't care, in the short term, if you reset esp.  It doesn't
store the stack pointer in the TIB but there are potential problems if
you generate any type of exception.  There is further potential in
cygwin in the event of a cygwin signal.

As I mentioned previously, cygwin uses the stack for thread local
storage so you can't just create a new stack and expect things to work.
You've worked around that by wrapping cygwin function calls with
save/restore operations.  That may work ok except in the case of
signals.

>>I already did earlier.  Let's not loop.
>
>You said that Windows has the TIB area. Ok, but if I restore the system
>stack before talking to windows, I don't see any problem.

I said more than that but, that's ok.

>>And what happens when the compiler decides to allocate more memory on
>>the stack than what seems possible from code inspection, like when
>>there's a signal?
>
>Well you've heard of sigaltstack() right?  That's an API where you call
>malloc() to create some stack space.  But I guess that API is "bad"
>because it means that the OS is no longer "controlling" where the stack
>is right?

I've heard of sigstack and sigalstack but cygwin hasn't.

cgf

--
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]