This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Do not set nothrow flag on recursive function with stack checking
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Eric Botcazou <ebotcazou at adacore dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 27 Apr 2018 11:09:32 +0200
- Subject: Re: [PATCH] Do not set nothrow flag on recursive function with stack checking
- References: <2604930.7AH0sRlHEb@polaris>
On Thu, Apr 26, 2018 at 4:29 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
> Hi,
>
> when stack checking is enabled in Ada, it is supposed to be able to handle the
> case of a recursive function that does essentially nothing. But in this case
> the IPA machinery will compute that the function is nothrow, which means that
> the Storage_Error exception cannot be caught by the caller.
>
> Tested on x86-64/Linux, OK for the mainline?
This looks not a generic enough fix to me - consider
void foo(void) { int a[100000]; a[0] = 1; a[99999] = 1; }
int main() { try { foo (); } catch (...) {} }
with -fnon-call-exceptions. If we'd like to catch the SEGV from stack overflows
then your fix doesn't handle the non-recursive case nor the case where
-fstack-check
is not supplied. But the compiler - when the accesses are in-range - will not
consider the accesses trapping.
So to me your attempt in fixing this isn't complete but a complete fix would
be quite pessimizing :/ (for -fnon-call-exceptions)
At least all this should be documented somewhere, that is, what to expect
when trying to catch stack faults in general with -fnon-call-exceptions
[-fstack-check].
Richard.
>
> 2018-04-26 Eric Botcazou <ebotcazou@adacore.com>
>
> * ipa-pure-const.c (check_call): In non-IPA mode, set can_throw flag
> for a recursive call that can throw if stack checking is enabled.
> (check_stmt): Fix formatting.
> (propagate_nothrow): Set can_throw for a recursive call if exceptions
> and stack checking are enabled.
> (pass_nothrow::execute): Do not set the nothrow flag if there is a
> recursive call that can throw and stack checking is enabled.
>
>
> 2018-04-26 Eric Botcazou <ebotcazou@adacore.com>
>
> * gnat.dg/stack_check4.adb: New test.
>
> --
> Eric Botcazou