Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 29132
Product:  
Component:  
Status: RESOLVED
Resolution: FIXED
Assigned To: roger@eyesopen.com
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: David Daney <daney@gcc.gnu.org>
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 29132 depends on: Show dependency tree
Show dependency graph
Bug 29132 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: 2006-09-22 16:51 Opened: 2006-09-18 20:46
The combination of GCC (r116604 or later) and binutils-2.17 creates bad
.eh_frame data causing SIGSEGV at runtime anytime an exception is thrown.

To reproduce just run the g++ testsuite.  All exception tests FAIL.

This problem is discussed further in:
http://gcc.gnu.org/ml/gcc-patches/2006-09/msg00732.html

------- Comment #1 From roger@eyesopen.com 2006-09-18 21:27 -------
Hi David,

I was wondering if you have a MIPS tree handy, whether you could easily
test the following single line patch:

Index: dwarf2out.c
===================================================================
*** dwarf2out.c (revision 117035)
--- dwarf2out.c (working copy)
*************** dwarf2out_begin_prologue (unsigned int l
*** 2572,2578 ****
    fde = &fde_table[fde_table_in_use++];
    fde->decl = current_function_decl;
    fde->dw_fde_begin = dup_label;
!   fde->dw_fde_current_label = NULL;
    fde->dw_fde_hot_section_label = NULL;
    fde->dw_fde_hot_section_end_label = NULL;
    fde->dw_fde_unlikely_section_label = NULL;
--- 2572,2578 ----
    fde = &fde_table[fde_table_in_use++];
    fde->decl = current_function_decl;
    fde->dw_fde_begin = dup_label;
!   fde->dw_fde_current_label = dup_label;
    fde->dw_fde_hot_section_label = NULL;
    fde->dw_fde_hot_section_end_label = NULL;
    fde->dw_fde_unlikely_section_label = NULL;

Due to all the abstraction with debugging formats, its difficult to tell the
order in which things get executed, and whether this initial value for
dw_fde_current_label survives long enough to avoid use of a set_loc.

Many thanks in advance,

------- Comment #2 From Andrew Pinski 2006-09-18 21:32 -------
The patch also went into the 4.1 branch.

------- Comment #3 From ddaney@avtrex.com 2006-09-18 21:32 -------
Subject: Re:  [4.2 Regression] Mips exception handling broken.

roger at eyesopen dot com wrote:
> ------- Comment #1 from roger at eyesopen dot com  2006-09-18 21:27 -------
> Hi David,
> 
> I was wondering if you have a MIPS tree handy, whether you could easily
> test the following single line patch:
> 
> Index: dwarf2out.c
> ===================================================================
> *** dwarf2out.c (revision 117035)
> --- dwarf2out.c (working copy)
> *************** dwarf2out_begin_prologue (unsigned int l
> *** 2572,2578 ****
>     fde = &fde_table[fde_table_in_use++];
>     fde->decl = current_function_decl;
>     fde->dw_fde_begin = dup_label;
> !   fde->dw_fde_current_label = NULL;
>     fde->dw_fde_hot_section_label = NULL;
>     fde->dw_fde_hot_section_end_label = NULL;
>     fde->dw_fde_unlikely_section_label = NULL;
> --- 2572,2578 ----
>     fde = &fde_table[fde_table_in_use++];
>     fde->decl = current_function_decl;
>     fde->dw_fde_begin = dup_label;
> !   fde->dw_fde_current_label = dup_label;
>     fde->dw_fde_hot_section_label = NULL;
>     fde->dw_fde_hot_section_end_label = NULL;
>     fde->dw_fde_unlikely_section_label = NULL;
> 
> Due to all the abstraction with debugging formats, its difficult to tell the
> order in which things get executed, and whether this initial value for
> dw_fde_current_label survives long enough to avoid use of a set_loc.
> 

I will try the patch now.  A full build with libgcj will take me several 
hours to build and test.

David Daney.

------- Comment #4 From ddaney@avtrex.com 2006-09-18 21:59 -------
Subject: Re:  [4.2 Regression] Mips exception handling broken.

roger at eyesopen dot com wrote:
> ------- Comment #1 from roger at eyesopen dot com  2006-09-18 21:27 -------
> Hi David,
> 
> I was wondering if you have a MIPS tree handy, whether you could easily
> test the following single line patch:
> 
> Index: dwarf2out.c
> ===================================================================
> *** dwarf2out.c (revision 117035)
> --- dwarf2out.c (working copy)
> *************** dwarf2out_begin_prologue (unsigned int l
> *** 2572,2578 ****
>     fde = &fde_table[fde_table_in_use++];
>     fde->decl = current_function_decl;
>     fde->dw_fde_begin = dup_label;
> !   fde->dw_fde_current_label = NULL;
>     fde->dw_fde_hot_section_label = NULL;
>     fde->dw_fde_hot_section_end_label = NULL;
>     fde->dw_fde_unlikely_section_label = NULL;
> --- 2572,2578 ----
>     fde = &fde_table[fde_table_in_use++];
>     fde->decl = current_function_decl;
>     fde->dw_fde_begin = dup_label;
> !   fde->dw_fde_current_label = dup_label;
>     fde->dw_fde_hot_section_label = NULL;
>     fde->dw_fde_hot_section_end_label = NULL;
>     fde->dw_fde_unlikely_section_label = NULL;
> 
> Due to all the abstraction with debugging formats, its difficult to tell the
> order in which things get executed, and whether this initial value for
> dw_fde_current_label survives long enough to avoid use of a set_loc.
> 
> Many thanks in advance,
> 

Preliminary results using: readelf --debug-dump=frames libstdc++.so show 
that this patch is working.

I now get:

00000064 00000024 00000068 FDE cie=00000000 pc=0003ed40..0003eed4
   Augmentation data:     00 00 00 00

   DW_CFA_advance_loc: 16 to 0003ed50
   DW_CFA_def_cfa_offset: 48
   DW_CFA_advance_loc: 24 to 0003ed68
   DW_CFA_offset: r16 at cfa-24
   DW_CFA_offset: r17 at cfa-20
   DW_CFA_offset: r18 at cfa-16
   DW_CFA_offset: r19 at cfa-12
   DW_CFA_offset: r20 at cfa-8


Both addresses shown for DW_CFA_advance_loc are within the range of PC 
for the FDE.  It will take (a lot) more time to see if the code actually 
works on my test platform, but it looks good to me so far.

David Daney.

------- Comment #5 From David Daney 2006-09-19 05:58 -------
OK, I finished running make -k check with a i686-linux -> mipsel-linux cross
compiler on my mips board for c, c++, java and there are only the 'normal'
failures (mostly attributable to running the testsuite on a remote board). 
Exception handling seems to be fixed with the Roger's patch applied.

I would say test it on a couple of other targets of your choice and then commit
it.

Thanks Roger for fixing this.

------- Comment #6 From Roger Sayle 2006-09-21 17:13 -------
Subject: Bug 29132

Author: sayle
Date: Thu Sep 21 17:13:33 2006
New Revision: 117114

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117114
Log:
2006-09-21  Roger Sayle  <roger@eyesopen.com>

        PR debug/29132
        * dwarf2out.c (dwarf2out_begin_prologue): Initialise the current label,
        dw_fde_current_label, to be the start of the function, i.e. the same
        value as dw_fde_begin.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/dwarf2out.c

------- Comment #7 From roger@eyesopen.com 2006-09-22 16:51 -------
Fixed on mainline (confirmed on mips-sgi-irix6.5).  It'll take another day or
two to backport to the 4.1 branch, as bootstrap and regtest on MIPS takes a
while.

------- Comment #8 From Roger Sayle 2006-09-24 15:56 -------
Subject: Bug 29132

Author: sayle
Date: Sun Sep 24 15:55:51 2006
New Revision: 117180

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117180
Log:

        PR debug/29132
        Backport from mainline
        * dwarf2out.c (dwarf2out_begin_prologue): Initialise the current label,
        dw_fde_current_label, to be the start of the function, i.e. the same
        value as dw_fde_begin.


Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/dwarf2out.c

------- Comment #9 From Andrew Pinski 2006-09-25 03:23 -------
Fixed.

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug