This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Exception handling: stack adjust in cleanups
- To: gcc-patches at gcc dot gnu dot org
- Subject: Exception handling: stack adjust in cleanups
- From: Andrew Haley <aph at cambridge dot redhat dot com>
- Date: Wed, 25 Apr 2001 18:08:05 +0100
I've been looking at a problem that breaks Java programs, and it seems
to be related to pending stack adjustments in cleanup routines.
What happens is that a label is emitted at the end of a cleanup while
a stack adjust is still pending; any execution path that branches to
the label ends up with a bad SP.
One miscompiled routine in libgcj is
gnu.gcj.runtime.FileDeleter.deleteOnExitNow().
This patch fixes the problem, but I'm not sure this is the ideal place
to do the stack adjust.
Andrew.
2001-04-25 Andrew Haley <aph@cambridge.redhat.com>
* except.c (expand_eh_region_end_cleanup): Force pending stack
adjust before emitting label that branches aroud cleanup code.
Index: except.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/except.c,v
retrieving revision 1.151
diff -u -r1.151 except.c
--- except.c 2001/04/04 00:48:51 1.151
+++ except.c 2001/04/25 16:57:02
@@ -733,6 +733,9 @@
if (protect_cleanup_actions)
expand_eh_region_end_must_not_throw (protect_cleanup_actions);
+ /* We need any stack adjustment complete before the around_label. */
+ do_pending_stack_adjust ();
+
/* We delay the generation of the _Unwind_Resume until we generate
landing pads. We emit a marker here so as to get good control
flow data in the meantime. */