new testcase for EH bug exposed by Java

Geoffrey Keating geoffk@thief.cygnus.com
Thu Dec 7 17:36:00 GMT 2000


This testcase exposes a case, on ppc ELF, where this comment in libgcc2.c:

  /* Now go back to our caller's stack frame.  If our caller's CFA register
     was saved in our stack frame, restore it; otherwise, assume the CFA
     register is SP and restore it to our CFA value.  */
  if (udata->saved[caller_udata->cfa_reg])
    caller_udata->cfa = get_reg (caller_udata->cfa_reg, udata, 0);
  else
    caller_udata->cfa = udata->cfa;

is wrong.  In this case, the DWARF2 output for `barf' correctly states
that the CFA is based off the frame pointer register, r31, not the
stack pointer; but _Jv_throw, which is called by it, does not need to
save this register.

To fix it needs a substantial rewrite of this bit of libgcc; it needs
to properly keep track of register contents as it unwinds frames.

-- 
Geoff Keating <geoffk@redhat.com>

===File ~/patches/gcc-javaehtest.patch======================
2000-12-07  Geoffrey Keating  <geoffk@redhat.com>

	* g++.old-deja/g++.other/eh3.C: New testcase.

Index: g++.old-deja/g++.other/eh3.C
===================================================================
RCS file: eh3.C
diff -N eh3.C
--- /dev/null	Tue May  5 13:32:27 1998
+++ eh3.C	Thu Dec  7 17:30:10 2000
@@ -0,0 +1,32 @@
+// Special g++ Options: -O
+typedef struct { } e;
+
+char *p;
+
+void _Jv_throw ();
+
+int barf (int len)
+{
+  char a[len];
+
+  p = a;
+  _Jv_throw ();
+  return 0;
+}
+
+void _Jv_throw ()
+{
+  e ex;
+  throw ex;
+}  
+
+int main ()
+{
+  try  {
+    barf (2);
+  }
+  catch (...) {
+  }
+
+  return 0;
+}
============================================================


More information about the Gcc-patches mailing list