public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug exp/27265] New: gdbtypes.c:3429: internal-error: type* init_complex_type(const char*, type*): Assertion `target_type->code () == TYPE_CODE_INT || target_type->code () == TYPE_CODE_FLT' failed.
@ 2021-01-28  8:48 vries at gcc dot gnu.org
  2021-01-28  8:54 ` [Bug exp/27265] " vries at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: vries at gcc dot gnu.org @ 2021-01-28  8:48 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=27265

            Bug ID: 27265
           Summary: gdbtypes.c:3429: internal-error: type*
                    init_complex_type(const char*, type*): Assertion
                    `target_type->code () == TYPE_CODE_INT ||
                    target_type->code () == TYPE_CODE_FLT' failed.
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: exp
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

...
$ gcc ~/hello.c
$ gdb -batch a.out -ex start -ex 'p $rip - 5i'
Temporary breakpoint 1 at 0x40050b

Temporary breakpoint 1, 0x000000000040050b in main ()
src/gdb/gdbtypes.c:3429: internal-error: type* init_complex_type(const char*,
type*): Assertion `target_type->code () == TYPE_CODE_INT || target_type->code
() == TYPE_CODE_FLT' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
...

The assert expects int or float, but instead we have pointer:
...
(gdb) p target_type->code ()
$1 = TYPE_CODE_PTR
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug exp/27265] gdbtypes.c:3429: internal-error: type* init_complex_type(const char*, type*): Assertion `target_type->code () == TYPE_CODE_INT || target_type->code () == TYPE_CODE_FLT' failed.
  2021-01-28  8:48 [Bug exp/27265] New: gdbtypes.c:3429: internal-error: type* init_complex_type(const char*, type*): Assertion `target_type->code () == TYPE_CODE_INT || target_type->code () == TYPE_CODE_FLT' failed vries at gcc dot gnu.org
@ 2021-01-28  8:54 ` vries at gcc dot gnu.org
  2021-01-28 10:04 ` vries at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: vries at gcc dot gnu.org @ 2021-01-28  8:54 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=27265

--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
Even easier reproducer:
...
$ gdb -batch -ex "p (void *)0 - 5i"
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug exp/27265] gdbtypes.c:3429: internal-error: type* init_complex_type(const char*, type*): Assertion `target_type->code () == TYPE_CODE_INT || target_type->code () == TYPE_CODE_FLT' failed.
  2021-01-28  8:48 [Bug exp/27265] New: gdbtypes.c:3429: internal-error: type* init_complex_type(const char*, type*): Assertion `target_type->code () == TYPE_CODE_INT || target_type->code () == TYPE_CODE_FLT' failed vries at gcc dot gnu.org
  2021-01-28  8:54 ` [Bug exp/27265] " vries at gcc dot gnu.org
@ 2021-01-28 10:04 ` vries at gcc dot gnu.org
  2021-01-28 11:05 ` vries at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: vries at gcc dot gnu.org @ 2021-01-28 10:04 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=27265

--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
Regression since gdb-10.1, with gdb-9.2 we have:
...
$ gdb -batch -ex "p (void *)0 + 5i"
Invalid number "5i".
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug exp/27265] gdbtypes.c:3429: internal-error: type* init_complex_type(const char*, type*): Assertion `target_type->code () == TYPE_CODE_INT || target_type->code () == TYPE_CODE_FLT' failed.
  2021-01-28  8:48 [Bug exp/27265] New: gdbtypes.c:3429: internal-error: type* init_complex_type(const char*, type*): Assertion `target_type->code () == TYPE_CODE_INT || target_type->code () == TYPE_CODE_FLT' failed vries at gcc dot gnu.org
  2021-01-28  8:54 ` [Bug exp/27265] " vries at gcc dot gnu.org
  2021-01-28 10:04 ` vries at gcc dot gnu.org
@ 2021-01-28 11:05 ` vries at gcc dot gnu.org
  2021-01-28 11:09 ` vries at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: vries at gcc dot gnu.org @ 2021-01-28 11:05 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=27265

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at sourceware dot org

--- Comment #3 from Tom de Vries <vries at gcc dot gnu.org> ---
Bisects to:
...
commit c34e87146628a14cf662dca46aac893d06502f52
Author: Tom Tromey <tom@tromey.com>
Date:   Wed Apr 1 14:09:52 2020 -0600

    Implement complex arithmetic
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug exp/27265] gdbtypes.c:3429: internal-error: type* init_complex_type(const char*, type*): Assertion `target_type->code () == TYPE_CODE_INT || target_type->code () == TYPE_CODE_FLT' failed.
  2021-01-28  8:48 [Bug exp/27265] New: gdbtypes.c:3429: internal-error: type* init_complex_type(const char*, type*): Assertion `target_type->code () == TYPE_CODE_INT || target_type->code () == TYPE_CODE_FLT' failed vries at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-01-28 11:05 ` vries at gcc dot gnu.org
@ 2021-01-28 11:09 ` vries at gcc dot gnu.org
  2021-01-28 11:26 ` vries at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: vries at gcc dot gnu.org @ 2021-01-28 11:09 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=27265

--- Comment #4 from Tom de Vries <vries at gcc dot gnu.org> ---
At the commit before, we have:
...
(gdb) p (void *)0 + 5i^M
Argument to arithmetic operation not a number or boolean.^M
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug exp/27265] gdbtypes.c:3429: internal-error: type* init_complex_type(const char*, type*): Assertion `target_type->code () == TYPE_CODE_INT || target_type->code () == TYPE_CODE_FLT' failed.
  2021-01-28  8:48 [Bug exp/27265] New: gdbtypes.c:3429: internal-error: type* init_complex_type(const char*, type*): Assertion `target_type->code () == TYPE_CODE_INT || target_type->code () == TYPE_CODE_FLT' failed vries at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-01-28 11:09 ` vries at gcc dot gnu.org
@ 2021-01-28 11:26 ` vries at gcc dot gnu.org
  2021-01-28 11:28 ` vries at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: vries at gcc dot gnu.org @ 2021-01-28 11:26 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=27265

--- Comment #5 from Tom de Vries <vries at gcc dot gnu.org> ---
Another reproducer:
...
$ gdb -batch -ex "p (_Decimal32)0.0 + 1i"
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug exp/27265] gdbtypes.c:3429: internal-error: type* init_complex_type(const char*, type*): Assertion `target_type->code () == TYPE_CODE_INT || target_type->code () == TYPE_CODE_FLT' failed.
  2021-01-28  8:48 [Bug exp/27265] New: gdbtypes.c:3429: internal-error: type* init_complex_type(const char*, type*): Assertion `target_type->code () == TYPE_CODE_INT || target_type->code () == TYPE_CODE_FLT' failed vries at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2021-01-28 11:26 ` vries at gcc dot gnu.org
@ 2021-01-28 11:28 ` vries at gcc dot gnu.org
  2021-01-28 12:50 ` vries at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: vries at gcc dot gnu.org @ 2021-01-28 11:28 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=27265

--- Comment #6 from Tom de Vries <vries at gcc dot gnu.org> ---
This seems to fix it:
...
diff --git a/gdb/valarith.c b/gdb/valarith.c
index 81d48aae82a..b4337492694 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -1171,8 +1171,12 @@ scalar_binop (struct value *arg1, struct value *arg2,
enum exp_
opcode op)
   type1 = check_typedef (value_type (arg1));
   type2 = check_typedef (value_type (arg2));

-  if (type1->code () == TYPE_CODE_COMPLEX
-      || type2->code () == TYPE_CODE_COMPLEX)
+  if ((type1->code () == TYPE_CODE_COMPLEX
+       && (type2->code () == TYPE_CODE_INT
+          || type2->code () == TYPE_CODE_FLT))
+      || ((type2->code () == TYPE_CODE_COMPLEX
+          && (type1->code () == TYPE_CODE_INT
+              || type1->code () == TYPE_CODE_FLT))))
     return complex_binop (arg1, arg2, op);

   if ((!is_floating_value (arg1)
...

We're back to:
...
$ gdb -batch -ex "p (void *)0 + 1i"
Argument to arithmetic operation not a number or boolean.
$ gdb -batch -ex "p (_Decimal32)0.0 + 1i"
Argument to arithmetic operation not a number or boolean.
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug exp/27265] gdbtypes.c:3429: internal-error: type* init_complex_type(const char*, type*): Assertion `target_type->code () == TYPE_CODE_INT || target_type->code () == TYPE_CODE_FLT' failed.
  2021-01-28  8:48 [Bug exp/27265] New: gdbtypes.c:3429: internal-error: type* init_complex_type(const char*, type*): Assertion `target_type->code () == TYPE_CODE_INT || target_type->code () == TYPE_CODE_FLT' failed vries at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2021-01-28 11:28 ` vries at gcc dot gnu.org
@ 2021-01-28 12:50 ` vries at gcc dot gnu.org
  2021-01-28 13:07 ` vries at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: vries at gcc dot gnu.org @ 2021-01-28 12:50 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=27265

--- Comment #7 from Tom de Vries <vries at gcc dot gnu.org> ---
Hmm, regressions at:
...
FAIL: gdb.base/complex-parts.exp: print (23 + 7i) + (17 + 10i)
FAIL: gdb.base/complex-parts.exp: print (5 + 5i) * (2 + 2i)
FAIL: gdb.base/complex-parts.exp: print (20 - 4i) / (3 + 2i)
...

Evidently I'm missing the TYPE_CODE_COMPLEX case.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug exp/27265] gdbtypes.c:3429: internal-error: type* init_complex_type(const char*, type*): Assertion `target_type->code () == TYPE_CODE_INT || target_type->code () == TYPE_CODE_FLT' failed.
  2021-01-28  8:48 [Bug exp/27265] New: gdbtypes.c:3429: internal-error: type* init_complex_type(const char*, type*): Assertion `target_type->code () == TYPE_CODE_INT || target_type->code () == TYPE_CODE_FLT' failed vries at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2021-01-28 12:50 ` vries at gcc dot gnu.org
@ 2021-01-28 13:07 ` vries at gcc dot gnu.org
  2021-02-05  9:56 ` cvs-commit at gcc dot gnu.org
  2021-02-05  9:58 ` vries at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: vries at gcc dot gnu.org @ 2021-01-28 13:07 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=27265

--- Comment #8 from Tom de Vries <vries at gcc dot gnu.org> ---
https://sourceware.org/pipermail/gdb-patches/2021-January/175553.html

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug exp/27265] gdbtypes.c:3429: internal-error: type* init_complex_type(const char*, type*): Assertion `target_type->code () == TYPE_CODE_INT || target_type->code () == TYPE_CODE_FLT' failed.
  2021-01-28  8:48 [Bug exp/27265] New: gdbtypes.c:3429: internal-error: type* init_complex_type(const char*, type*): Assertion `target_type->code () == TYPE_CODE_INT || target_type->code () == TYPE_CODE_FLT' failed vries at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2021-01-28 13:07 ` vries at gcc dot gnu.org
@ 2021-02-05  9:56 ` cvs-commit at gcc dot gnu.org
  2021-02-05  9:58 ` vries at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-02-05  9:56 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=27265

--- Comment #9 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom de Vries <vries@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ae7104966177c7bcb7bef9e1445489d9d2f97f06

commit ae7104966177c7bcb7bef9e1445489d9d2f97f06
Author: Tom de Vries <tdevries@suse.de>
Date:   Fri Feb 5 10:56:39 2021 +0100

    [gdb/exp] Fix assert when adding ptr to imaginary unit

    I'm running into this assertion failure:
    ...
    $ gdb -batch -ex "p (void *)0 - 5i"
    gdbtypes.c:3430: internal-error: \
      type* init_complex_type(const char*,   type*): Assertion \
      `target_type->code () == TYPE_CODE_INT \
       || target_type->code () == TYPE_CODE_FLT' failed.
    A problem internal to GDB has been detected,
    further debugging may prove unreliable.
    ...

    This is a regression since commit c34e8714662 "Implement complex
arithmetic".
    Before that commit we had:
    ...
    (gdb) p (void *)0 - 5i
    Argument to arithmetic operation not a number or boolean.
    ...

    Fix this in complex_binop by throwing an error, such that we have:
    ...
    (gdb) print (void *)0 - 5i
    Argument to complex arithmetic operation not supported.
    ...

    Tested on x86_64-linux.

    gdb/ChangeLog:

    2021-02-05  Tom de Vries  <tdevries@suse.de>

            PR exp/27265
            * valarith.c (complex_binop): Throw an error if complex type can't
            be created.

    gdb/testsuite/ChangeLog:

    2021-02-05  Tom de Vries  <tdevries@suse.de>

            PR exp/27265
            * gdb.base/complex-parts.exp: Add tests.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug exp/27265] gdbtypes.c:3429: internal-error: type* init_complex_type(const char*, type*): Assertion `target_type->code () == TYPE_CODE_INT || target_type->code () == TYPE_CODE_FLT' failed.
  2021-01-28  8:48 [Bug exp/27265] New: gdbtypes.c:3429: internal-error: type* init_complex_type(const char*, type*): Assertion `target_type->code () == TYPE_CODE_INT || target_type->code () == TYPE_CODE_FLT' failed vries at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2021-02-05  9:56 ` cvs-commit at gcc dot gnu.org
@ 2021-02-05  9:58 ` vries at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: vries at gcc dot gnu.org @ 2021-02-05  9:58 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=27265

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #10 from Tom de Vries <vries at gcc dot gnu.org> ---
Patch with test-case committed, marking resolved-fixed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-02-05  9:58 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-28  8:48 [Bug exp/27265] New: gdbtypes.c:3429: internal-error: type* init_complex_type(const char*, type*): Assertion `target_type->code () == TYPE_CODE_INT || target_type->code () == TYPE_CODE_FLT' failed vries at gcc dot gnu.org
2021-01-28  8:54 ` [Bug exp/27265] " vries at gcc dot gnu.org
2021-01-28 10:04 ` vries at gcc dot gnu.org
2021-01-28 11:05 ` vries at gcc dot gnu.org
2021-01-28 11:09 ` vries at gcc dot gnu.org
2021-01-28 11:26 ` vries at gcc dot gnu.org
2021-01-28 11:28 ` vries at gcc dot gnu.org
2021-01-28 12:50 ` vries at gcc dot gnu.org
2021-01-28 13:07 ` vries at gcc dot gnu.org
2021-02-05  9:56 ` cvs-commit at gcc dot gnu.org
2021-02-05  9:58 ` vries at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).