g++ Bug? use of alloca in a function prevents exception handler walkback on ppc linux

Franz Sirl Franz.Sirl-kernel@lauterbach.com
Mon Dec 18 06:13:00 GMT 2000


At 01:20 2000-12-15, Geoff Keating wrote:
> > From: Franz Sirl <Franz.Sirl-kernel@lauterbach.com>
> > Date: Thu, 14 Dec 2000 23:31:09 +0100
>
> > > It's a libgcc bug.
> >
> > But hard to fix?
>
>It needs some rewriting, but then lots of testing.  Not very hard, but
>not easy either.

Hmm, do you have a testcase that is known to fail because of this bug? 
Kevin's testcase forces the frame_pointer_needed to 1 anyway, and I think 
you mean a testcase where the frame pointer gets eliminated to the stack 
pointer. Hmm, looking at older changelogs, isn't the libgcc2 infrastructure 
already there:

2000-06-26  Andrew Macleod <amacleod@cygnus.com>
             Jason Merrill <jason@redhat.com>

         * dwarf2.h (enum dwarf_call_frame_info): Add
         DW_CFA_def_cfa_expression.
         * dwarf2out.c (union dw_cfi_oprnd_struct): Add a pointer to a
         dw_loc_descr_struct entry.
         (struct cfa_loc): New structure to track a CFA location.
         (lookup_cfa): Take a cfa_loc parameter instead of a reg and an offset.
         (lookup_cfa_1): Take a cfa_loc parameter instead of a reg and an
         offset, plus handle DW_CFA_def_cfa_expression.
         (def_cfa_1): Use to be dwarf2out_def_cfa, only now it uses a
         cfa_loc record.
         (dwarf2out_def_cfa): Entry point maintained for compatability.
         (dwarf_cfi_name): Add DW_CFA_def_cfa_expression.
         (cfa_reg, cfa_offset): Replace with cfa_loc record 'cfa'.
         (cfa_store_reg, cfa_store_offset): Replace with cfa_loc 'cfa_store'.
         (initial_return_save, dwarf2out_stack_adjust): Use cfa.reg, not
         cfa_reg.
         (dwarf2out_frame_debug_expr): Use new cfa_loc records. Recognize rtl
         sequences for the new DW_CFA_def_cfa_expression record.
         (dwarf2out_frame_debug): Use new variables/fields.A
         (output_cfi): Handle DW_CFA_def_cfa_expression.
         (output_cfa_loc): New function to generate a CFI record for
         DW_CFA_def_cfa_expression.
         (get_cfa_from_loc_descr): New function to get a cfa_loc record from
         a dw_loc_descr sequeunce.
         (build_loc_descr): Build a dw_loc_descr from a cfa_loc record.
         (dwarf_stack_op_name, new_loc_descr, add_loc_descr, size_of_loc_descr,
         size_of_locs, output_loc_operands, output_loc_sequence): Move into
         unwind info section.
         * frame.h (frame_state): Add base_offset and indirect fields.
         * frame-dwarf2.c (decode_stack_op): New function to interpret a
         dw_loc_descr operation.
         (execute_cfa_insn): Add support for DW_CFA_def_cfa_expression.
         (struct frame_state): Add base offset and indirect fields.
         * libgcc2.c (next_stack_level): Support indirect loading for CFA.


Do we need even more?

> > Your patch is against the current mainline, but mainline compiles a 
> correctly
> > throwing binary with Kevin's testcase. Do you have another testcase or 
> is the
> > current mainline already fixed and your patch superflous now? If it is 
> fixed,
> > it must have happened recently, since the 20001106 compiler still 
> produced a
> > failing binary.
>
>It worries me that this stopped failing.  It probably indicates we
>lost an optimisation.  I don't believe the underlying bug was fixed.

The code is nearly the same (I compared the assembly), I believe this was a 
temporary failure and not related to the bug you are referring to. What 
makes me wonder though is the code generated for "thrower" in Kevin's 
testcase, that looks bogus. It seems to me that the code is using an 
uninitialized and unallocated stackslot for aExc, which overlays (!) with 
the register save area, r31 in this example. The bug is already in the 
initial RTL dump, which would suggest that except.c and cp/except.c have a 
bug here.

> > Anyway, Kevin is working with gcc-2.95.3 so I'll look into backporting 
> your
> > fix, cause I don't have time to do gcc-2.97 RPM's before xmas.
>
>Sure.  As a workaround, this is suitable for 2.95.3.

As this bug turned out to be a different one than you thought (?), the 
solution for gcc-2.95.3 is really simple and related to the unofficial 
DWARF EH patch used on Linux/PPC. It turns out the patch missed to call 
dwarf2out_def_cfa() after the framepointer activating "mr 31,1". Fixing 
this lets the testcase succeed.

Kevin, I'll upload new RPM's as soon as the build finished.

Franz.



More information about the Gcc mailing list