[gccsdk] ***Fatal error: Stack corruption detected***

Jeffrey Lee me at phlamethrower.co.uk
Fri May 21 00:22:35 PDT 2010


On Tue, 18 May 2010, Jeffrey Lee wrote:

> The easiest fix is likely to be to amend the NULL check that was added to 
> __gcc_alloca_restore() for bug #174 so that it also returns if
> (chunk->block != block). I'd have tested this myself by now, but something
> is preventing my current source tree from building, so I'll have to try again 
> in a day or two when I have some more time available to get my tree
> working again.

After fixing my build issues, I can confirm that the attached patch fixes 
the problems I've been seeing. Want me to enter it as a bug report so it 
doesn't get forgotten?

Cheers,

- Jeffrey
-------------- next part --------------
Index: gcc4/recipe/files/gcc/libunixlib/gcccompat/galloca.c
===================================================================
--- gcc4/recipe/files/gcc/libunixlib/gcccompat/galloca.c	(revision 4622)
+++ gcc4/recipe/files/gcc/libunixlib/gcccompat/galloca.c	(working copy)
@@ -193,11 +193,13 @@
   /* Bug 174: If GCC determines that a call to __gcc_alloca can never be reached,
      it will optimise it away. However, the subsequent call to __gcc_alloca_restore
      is left intact and, as a block was never allocated, crashes because
-     chunk == NULL . */
-  if (chunk == NULL)
+     chunk == NULL .
+     We also need to protect against chunk->block != block, for the situation where
+     __gcc_alloca has been skipped for this stack frame but the chunk list is
+     nonempty due to use of __gcc_alloca in a parent stack frame */
+  if ((chunk == NULL) || (chunk->block != block))
     return;
 
-  assert (chunk->block == block);
   assert (chunk->fp == callee_fp);
 
   /* Delete chunk with id block.  */


More information about the gcc mailing list