Recursive SIGSEGV question
Jonny Grant
jg@jguk.org
Mon Mar 25 16:13:00 GMT 2019
On 25/03/2019 15:47, Andrew Haley wrote:
> On 3/25/19 2:01 PM, Florian Weimer wrote:
>> * Xi Ruoyao:
>>
>>> 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.
>>
>> I think âimpossibleâ is too strong.
>
> It is. We do it with stack banging and a few guard pages in the HotSpot JVM.
> The problem is that recovering well enough to throw an exception requires
> some quite hairy non-portable code.
Sounds good!
I had expected that GCC (eg on x86) generated code just kept track of
the base and max SP register, and so would easily be able to call
abort() and printf "Stack %zu limit reached - Abort\n".
I can see it would be an overhead, and difficult to recover well enough
to abort() after a message.
Jonny
More information about the Gcc-help
mailing list