[cfe-dev] stack overflow detection?

Jean Lee xiaoyur347 at gmail.com
Tue Sep 17 15:57:07 PDT 2013


gcc support stack overflow, but I never try before.

http://gcc.gnu.org/onlinedocs/gcc-4.3.6/gcc/Code-Gen-Options.html#Code-Gen-Options

-fstack-check
Generate code to verify that you do not go beyond the boundary of the
stack. You should specify this flag if you are running in an environment
with multiple threads, but only rarely need to specify it in a
single-threaded environment since stack overflow is automatically detected
on nearly all systems if there is only one stack.
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.
在 2013年9月18日 上午6:22,"John Criswell" <criswell at illinois.edu>写道:

> On 9/17/13 5:18 PM, Greg Fitzgerald wrote:
>
>> Thanks for the quick replies!
>>
>>
>>  If you want dynamic detection, then Address Sanitizer (which is built
>>> into Clang) or SAFECode
>>>
>> Dynamic detection.  I tried with Address Sanitizer and no luck
>> out-of-the-box.  I think it can detect stack-buffer-overflow (aka
>> stack corruption), but not stack overflow.  I also tried running the
>> code with ASan inside a pthread with heap-allocated memory for its
>> stack, but since the pthread library itself is not instrumented, it
>> did not detect the heap-buffer-overflow when the thread's stack
>> overflows.
>>
>
> I think I misunderstood.  Are you asking about the case in which the stack
> is about to exceed the limit set by the operating system?  I assumed you
> were talking about stack buffer overflows.
>
> -- John T.
>
> ______________________________**_________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/**mailman/listinfo/cfe-dev<http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130918/f1109317/attachment.html>


More information about the cfe-dev mailing list