diff mbox

New FAIL on gdb.base/complex-parts.exp - unix/-m32

Message ID 87k1ftu7jb.fsf@tromey.com
State New
Headers show

Commit Message

Tom Tromey April 16, 2019, 6:30 p.m. UTC
>>>>> "Andrew" == Andrew Burgess <andrew.burgess@embecosm.com> writes:

Andrew> The problem is that GDB tries to find a builtin floating point type of
Andrew> the correct size in order to reuse the name of that type as the name
Andrew> for the components of the complex type being built.

This patch caused a crash on an internal test case.
Let me know what you think of the appended.

thanks,
Tom

commit bf3507f7fcb6331401f9fd8eb7f1fad25ebfdf23
Author: Tom Tromey <tromey@adacore.com>
Date:   Tue Apr 16 12:12:09 2019 -0600

    Avoid crash in dwarf2_init_complex_target_type
    
    After commit 35add35 ("gdb: Fix failure in gdb.base/complex-parts.exp
    for x86-32"), dwarf2_init_complex_target_type can crash if "tt" is
    nullptr.  This patch avoids the problem by checking for this case.
    
    No test case because I don't know a good way to write one; it was
    found by an internal AdaCore test case that apparently uses a 16 bit
    floating point type.
    
    gdb/ChangeLog:
            * dwarf2read.c (dwarf2_init_complex_target_type): Check "tt"
            against nullptr before use.

Comments

Andrew Burgess April 17, 2019, 12:03 a.m. UTC | #1
* Tom Tromey <tom@tromey.com> [2019-04-16 12:30:48 -0600]:

> >>>>> "Andrew" == Andrew Burgess <andrew.burgess@embecosm.com> writes:
> 
> Andrew> The problem is that GDB tries to find a builtin floating point type of
> Andrew> the correct size in order to reuse the name of that type as the name
> Andrew> for the components of the complex type being built.
> 
> This patch caused a crash on an internal test case.
> Let me know what you think of the appended.
> 
> thanks,
> Tom
> 
> commit bf3507f7fcb6331401f9fd8eb7f1fad25ebfdf23
> Author: Tom Tromey <tromey@adacore.com>
> Date:   Tue Apr 16 12:12:09 2019 -0600
> 
>     Avoid crash in dwarf2_init_complex_target_type
>     
>     After commit 35add35 ("gdb: Fix failure in gdb.base/complex-parts.exp
>     for x86-32"), dwarf2_init_complex_target_type can crash if "tt" is
>     nullptr.  This patch avoids the problem by checking for this case.
>     
>     No test case because I don't know a good way to write one; it was
>     found by an internal AdaCore test case that apparently uses a 16 bit
>     floating point type.
>     
>     gdb/ChangeLog:
>             * dwarf2read.c (dwarf2_init_complex_target_type): Check "tt"
>             against nullptr before use.
> 
> diff --git a/gdb/ChangeLog b/gdb/ChangeLog
> index ba1300d57ef..9281d822ade 100644
> --- a/gdb/ChangeLog
> +++ b/gdb/ChangeLog
> @@ -1,3 +1,8 @@
> +2019-04-16  Tom Tromey  <tromey@adacore.com>
> +
> +	* dwarf2read.c (dwarf2_init_complex_target_type): Check "tt"
> +	against nullptr before use.
> +
>  2019-04-15  Leszek Swirski  <leszeks@google.com>
>  
>  	* amd64-tdep.c (amd64_classify_aggregate): Use cp_pass_by_reference
> diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
> index 0873028e438..16bf2404a21 100644
> --- a/gdb/dwarf2read.c
> +++ b/gdb/dwarf2read.c
> @@ -17566,7 +17566,7 @@ dwarf2_init_complex_target_type (struct dwarf2_cu *cu,
>    /* If the type we found doesn't match the size we were looking for, then
>       pretend we didn't find a type at all, the complex target type we
>       create will then be nameless.  */
> -  if (TYPE_LENGTH (tt) * TARGET_CHAR_BIT != bits)
> +  if (tt != nullptr && TYPE_LENGTH (tt) * TARGET_CHAR_BIT != bits)
>      tt = nullptr;
>  
>    const char *name = (tt == nullptr) ? nullptr : TYPE_NAME (tt);

Thank you, that looks great.

Feel free to push this.

Andrew
diff mbox

Patch

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ba1300d57ef..9281d822ade 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@ 
+2019-04-16  Tom Tromey  <tromey@adacore.com>
+
+	* dwarf2read.c (dwarf2_init_complex_target_type): Check "tt"
+	against nullptr before use.
+
 2019-04-15  Leszek Swirski  <leszeks@google.com>
 
 	* amd64-tdep.c (amd64_classify_aggregate): Use cp_pass_by_reference
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 0873028e438..16bf2404a21 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -17566,7 +17566,7 @@  dwarf2_init_complex_target_type (struct dwarf2_cu *cu,
   /* If the type we found doesn't match the size we were looking for, then
      pretend we didn't find a type at all, the complex target type we
      create will then be nameless.  */
-  if (TYPE_LENGTH (tt) * TARGET_CHAR_BIT != bits)
+  if (tt != nullptr && TYPE_LENGTH (tt) * TARGET_CHAR_BIT != bits)
     tt = nullptr;
 
   const char *name = (tt == nullptr) ? nullptr : TYPE_NAME (tt);