Re: -fstack-check on MIPS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Pan ruochen <panruochen@xxxxxxxxx> writes:

> 2009/7/2 Ian Lance Taylor <iant@xxxxxxxxxx>:
>> As the documentation of the option says:
>>
>>     Note that this switch does not actually cause checking to be done;
>>     the operating system must do that.  The switch causes generation
>>     of code to ensure that the operating system sees the stack being
>>     extended.
>>
>> The store deep in the stack frame is what tells the OS that the stack is
>> being extended.
>>
>> There is currently no option to control the default offset to use.
>>
>> Ian
>>
>
> What I don't understand is when the check action is taken since there
> is no additional code on the return from a function call.
> There seems to be no way to guarantee OS will get control just at the
> moment when CPU is returned from a function, so OS may miss the chance
> to do the check on the stack.

The intention is that if the stack is not mapped, the store will trigger
a fault--an access to an invalid memory address.  Based on the address,
the OS will recognize that this access is to the stack, and will
automatically increase the stack size.  Or, if that is not possible, the
OS will halt the program.

I suspect that -fstack-check does not do what you think it does.  It
doesn't check that you are using the stack correctly.  It checks that
you do not run past the end of the stack.  This avoids a certain class
of errors which can arise when using functions with very large stack
frames in a multi-threaded program: such functions can accidentally skip
into the stack frame of a different thread.

Ian


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux