Bug 25266 - SJLJ exception handling fails in function using alloca()
Summary: SJLJ exception handling fails in function using alloca()
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 3.4.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: EH, sjlj-eh, wrong-code
Depends on: 19774
Blocks:
  Show dependency treegraph
 
Reported: 2005-12-05 14:36 UTC by Takashi Ono
Modified: 2012-07-30 23:16 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-12-06 23:56:51


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Takashi Ono 2005-12-05 14:36:14 UTC
On both
gcc (GCC) 3.3.5 (propolice)
and
gcc.exe (GCC) 3.4.2 (mingw-special)
the following code does not work properly.

Its output should be test1<nl>test2<nl>test3<nl>, but the 3rd output gets malformed.

It seems to me the stack is unwindded too far by sjlj-eh at the entrance of catch block and the region obtained by alloca() is destroyed.

<test.cpp>---------------
#include "malloc.h"
#include "string.h"
#include "stdio.h"
static void foo2();
int main(int, char**)
{
  int a=0;
  a=a+1;
  char *b=(char *)alloca(10);
  strcpy(b,"test");
  printf("%s%d\n", b, a);
  try {
    a++;
    printf("%s%d\n", b, a);
    foo2();
  }
  catch(...){
    a++;
    printf("%s%d\n", b, a);
  }
  return 0;
}

static void foo2()
{
  int i=1;
  throw(i);
}
Comment 1 Andrew Pinski 2005-12-06 23:56:51 UTC
Confirmed, very much related to PR 19774.
Comment 2 Steven Bosscher 2012-07-30 23:16:37 UTC
Fixed by tree-ssa's EH lowering and builtin_alloca handling.