diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2006-02-15 10:36:13 +0100 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2006-02-15 10:36:13 +0100 |
commit | 463af61db6f1632c127219e81b801a5c199cd5f9 (patch) | |
tree | 3cf1687d589bcb03acddb840f5c022aa2b6bfa79 | |
parent | 3a0462b3e6dd2c22843f7715dd49d2ce28883835 (diff) | |
download | gcc-463af61db6f1632c127219e81b801a5c199cd5f9.zip gcc-463af61db6f1632c127219e81b801a5c199cd5f9.tar.gz gcc-463af61db6f1632c127219e81b801a5c199cd5f9.tar.bz2 |
s-stchop.adb (Stack_Check): Raise Storage_Error if the argument has wrapped around.
2006-02-13 Eric Botcazou <ebotcazou@adacore.com>
* s-stchop.adb (Stack_Check): Raise Storage_Error if the argument has
wrapped around.
From-SVN: r111050
-rw-r--r-- | gcc/ada/s-stchop.adb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/gcc/ada/s-stchop.adb b/gcc/ada/s-stchop.adb index 2f9c809..f1478f3 100644 --- a/gcc/ada/s-stchop.adb +++ b/gcc/ada/s-stchop.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1999-2005 Free Software Foundation, Inc. -- +-- Copyright (C) 1999-2006 Free Software Foundation, Inc. -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -179,6 +179,20 @@ package body System.Stack_Checking.Operations is Frame_Address : constant System.Address := Marker'Address; begin + -- The parameter may have wrapped around in System.Address arithmetics. + -- In that case, we have no other choices than raising the exception. + + if (Stack_Grows_Down and then + Stack_Address > Frame_Address) + or else + (not Stack_Grows_Down and then + Stack_Address < Frame_Address) + then + Ada.Exceptions.Raise_Exception + (E => Storage_Error'Identity, + Message => "stack overflow detected"); + end if; + -- This function first does a "cheap" check which is correct -- if it succeeds. In case of failure, the full check is done. -- Ideally the cheap check should be done in an optimized manner, |