Re: Recursive SIGSEGV question

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

 



On Mon, Mar 25, 2019 at 09:55:56PM +0800, Xi Ruoyao wrote:
> On 2019-03-25 13:06 +0000, Jonny Grant wrote:
> > I built & ran with the Sanitizer, it seems it's also stack overflow 
> > within the operator new()
> > 
> > I had thoughts GCC would generate code that monitored the stack size and 
> > aborted with a clear message when the stack size was exceeded. Looked 
> > online, and it doesn't seem to be the case.
> 
> Impossible.  We can't distinguish "stack overflow" with other segmentation
> faults.  For example
> 
> int foo() {volatile char p[10000000]; p[0] = 1;}
> 
> and
> 
> int foo() {
>  volatile char a;
>  (&a)[-9999999] = 1;
> }
> 
> may be compiled to exactly same machine code.  Now which one is a stack
> overflow?

The second one is undefined behaviour so it can do whatever you want.
That includes reporting it as a stack overflow.  There in general is no
way to fix this, it has nothing to do with the problem at hand.


Segher



[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