[PATCH, testsuite]: RFA: Fix gcc.c-torture/execute/multi-ix.c stack corruption for small STACK_SIZEs
Uros Bizjak
ubizjak@gmail.com
Wed Mar 26 21:14:00 GMT 2008
Hello!
When gcc.c-torture/execute/multi-ix.c is compiled using i.e.
-DSTACK_SIZE=2048, CHUNK gets calculated as 5.
The problem is, that we assign a0[i0] = i0, where i0 is calculated via
s() and i0=a0[0] as 39.
Having a0[39] = 39; where
typedef int l[CHUNK];
...
l a0, a1, a2, a3, a4, a5, a6, a7, a8, a9;
surely leads to troubles when CHUNK is less than 40.
2008-03-26 Uros Bizjak <ubizjak@gmail.com>
* gcc.c-torture/execute/multi-ix.c: Limit CHUNK size between 1
and 500.
(main): Exit early for CHUNK less than 40 to avoid stack corruption.
Patch was tested on x86_64-pc-linux-gnu.
OK for mainline?
On a related note, I find a bit suspicious that following test:
--cut here--
int main()
{
printf ("%i\n", (STACK_SIZE-40*sizeof(int)-256*sizeof(void
*))/40/sizeof(int));
return 0;
}
--cut here--
$gcc -O2 -m64 -DSTACK_SIZE=2048
$a.out
-1717986920
returns quite unexpected result. I think that the test on LP64 targets
should return zero.
Uros.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: p.diff.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20080326/ddadd19e/attachment.txt>
More information about the Gcc-patches
mailing list