public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug exp/27070] New: gdb crashes when comparing 2 instances of the same enum
@ 2020-12-14 17:01 ssbssa at sourceware dot org
  2020-12-14 18:14 ` [Bug exp/27070] " ssbssa at sourceware dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: ssbssa at sourceware dot org @ 2020-12-14 17:01 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 27070
           Summary: gdb crashes when comparing 2 instances of the same
                    enum
           Product: gdb
           Version: 10.1
            Status: NEW
          Severity: normal
          Priority: P2
         Component: exp
          Assignee: unassigned at sourceware dot org
          Reporter: ssbssa at sourceware dot org
  Target Milestone: ---

Consider the following example:

enum.h:
enum e
{
  zero,
  one,
};

enum-1.c:
#include "enum.h"
int func();
enum e e1;
int main()
{
  return e1 + func();
}

enum-2.c:
#include "enum.h"
enum e e2;
int func()
{
  return e2;
}

$ gcc -g -oenum enum-1.c enum-2.c
$ gdb -q enum.exe
Reading symbols from enum.exe...
(gdb) py print(gdb.parse_and_eval("e1").type==gdb.parse_and_eval("e2").type)

Thread 1 received signal SIGSEGV, Segmentation fault.
[Switching to Thread 6184.0x1cc4]
check_typedefDuring symbol reading: incomplete CFI data; unspecified registers
(e.g., rax) at 0x55613a
 (type=0x0) at C:/src/repos/binutils-gdb.git/gdb/gdbtypes.c:2745
2745      while (type->code () == TYPE_CODE_TYPEDEF)
                            ^
(top-gdb) bt
#0  check_typedef (type=0x0) at
C:/src/repos/binutils-gdb.git/gdb/gdbtypes.c:2745
#1  0x000000000055d884 in check_types_equal (worklist=0xeacf3c0, type2=0x0,
type1=<optimized out>) at C:/src/repos/binutils-gdb.git/gdb/gdbtypes.c:3986
#2  check_types_worklist (cache=<optimized out>, worklist=<optimized out>) at
C:/src/repos/binutils-gdb.git/gdb/gdbtypes.c:4106
#3  types_deeply_equal (type1=<optimized out>, type1@entry=0x10e0ae50,
type2=<optimized out>) at C:/src/repos/binutils-gdb.git/gdb/gdbtypes.c:4129
#4  0x000000000061f4d0 in typy_richcompare (self=0x1102d030, other=0x11081198,
op=2) at C:/src/repos/binutils-gdb.git/gdb/python/py-type.c:1049
#5  0x000000006ba3b23d in python27!PyObject_RichCompare () from
c:\gdb\gdb-libs64\Python27\python27.dll
#6  0x000000006ba9ed3f in python27!_PyEval_SliceIndex () from
c:\gdb\gdb-libs64\Python27\python27.dll
#7  0x000000006ba981dc in python27!PyEval_EvalFrameEx () from
c:\gdb\gdb-libs64\Python27\python27.dll
#8  0x000000006ba9ca11 in python27!PyEval_EvalCodeEx () from
c:\gdb\gdb-libs64\Python27\python27.dll
#9  0x000000006bad9040 in python27!PyRun_FileExFlags () from
c:\gdb\gdb-libs64\Python27\python27.dll
#10 0x000000006bad8e8f in python27!PyRun_StringFlags () from
c:\gdb\gdb-libs64\Python27\python27.dll
#11 0x000000006bad809e in python27!PyRun_SimpleStringFlags () from
c:\gdb\gdb-libs64\Python27\python27.dll
During symbol reading: incomplete CFI data; DW_CFA_restore unspecified
register rbx (#1) at 0x62af64
#12 0x000000000062af7b in python_command (arg=<optimized out>,
from_tty=<optimized out>) at
C:/src/repos/binutils-gdb.git/gdb/python/python.c:439
#13 0x0000000000489e72 in cmd_func (cmd=0x0, args=0xfffffffffdcb98c0 <error:
Cannot access memory at address 0xfffffffffdcb98c0>, from_tty=0)
    at C:/src/repos/binutils-gdb.git/gdb/cli/cli-decode.c:2181
#14 0x00000000006d2f3c in execute_command (p=<optimized out>,
p@entry=0x10df1ea0 "py
print(gdb.parse_and_eval(\"e1\").type==gdb.parse_and_eval(\"e2\").type)",
from_tty=1)
    at C:/src/repos/binutils-gdb.git/gdb/top.c:668
#15 0x000000000052ed54 in command_handler (command=0x10df1ea0 "py
print(gdb.parse_and_eval(\"e1\").type==gdb.parse_and_eval(\"e2\").type)") at
C:/src/repos/binutils-gdb.git/gdb/event-top.c:588
#16 0x000000000052f092 in command_line_handler (rl=...) at
C:/src/repos/binutils-gdb.git/gdb/event-top.c:773
#17 0x000000000052f5c3 in gdb_rl_callback_handler (rl=0x10df1e00 "py
print(gdb.parse_and_eval(\"e1\").type==gdb.parse_and_eval(\"e2\").type)") at
C:/src/repos/binutils-gdb.git/gdb/event-top.c:219
#18 0x000000000074144c in rl_callback_read_char () at
C:/src/repos/binutils-gdb.git/readline/readline/callback.c:281
#19 0x000000000052e33e in gdb_rl_callback_read_char_wrapper_noexcept () at
C:/src/repos/binutils-gdb.git/gdb/event-top.c:177
#20 0x000000000052f474 in gdb_rl_callback_read_char_wrapper
(client_data=<optimized out>) at
C:/src/repos/binutils-gdb.git/gdb/event-top.c:193
#21 0x000000000052e0a2 in stdin_event_handler (error=<optimized out>,
client_data=0x3ad740) at C:/src/repos/binutils-gdb.git/gdb/event-top.c:516
#22 0x0000000000811138 in handle_file_event (ready_mask=<optimized out>,
file_ptr=0x10db4f70) at
C:/src/repos/binutils-gdb.git/gdbsupport/event-loop.cc:548
#23 gdb_wait_for_event (block=block@entry=1) at
C:/src/repos/binutils-gdb.git/gdbsupport/event-loop.cc:698
#24 0x00000000008112c7 in gdb_wait_for_event (block=1) at
C:/src/repos/binutils-gdb.git/gdbsupport/event-loop.cc:575
#25 gdb_do_one_event () at
C:/src/repos/binutils-gdb.git/gdbsupport/event-loop.cc:215
#26 0x00000000005b3c2d in start_event_loop () at
C:/src/repos/binutils-gdb.git/gdb/main.c:360
#27 captured_command_loop () at C:/src/repos/binutils-gdb.git/gdb/main.c:420
#28 0x00000000005b5fb5 in captured_main (data=0xeacfdc0) at
C:/src/repos/binutils-gdb.git/gdb/main.c:1257
#29 gdb_main (args=args@entry=0xeacfe20) at
C:/src/repos/binutils-gdb.git/gdb/main.c:1272
#30 0x0000000000a1f2f7 in main (argc=3, argv=0x267f40) at
C:/src/repos/binutils-gdb.git/gdb/gdb.c:32


The reason is that in check_types_equal the types of FIELD_LOC_KIND_ENUMVAL are
added to the worklist, even though they are always NULL for enums.

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

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

* [Bug exp/27070] gdb crashes when comparing 2 instances of the same enum
  2020-12-14 17:01 [Bug exp/27070] New: gdb crashes when comparing 2 instances of the same enum ssbssa at sourceware dot org
@ 2020-12-14 18:14 ` ssbssa at sourceware dot org
  2020-12-19 12:43 ` cvs-commit at gcc dot gnu.org
  2020-12-19 12:46 ` ssbssa at sourceware dot org
  2 siblings, 0 replies; 4+ messages in thread
From: ssbssa at sourceware dot org @ 2020-12-14 18:14 UTC (permalink / raw)
  To: gdb-prs

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

Hannes Domani <ssbssa at sourceware dot org> changed:

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

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

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

* [Bug exp/27070] gdb crashes when comparing 2 instances of the same enum
  2020-12-14 17:01 [Bug exp/27070] New: gdb crashes when comparing 2 instances of the same enum ssbssa at sourceware dot org
  2020-12-14 18:14 ` [Bug exp/27070] " ssbssa at sourceware dot org
@ 2020-12-19 12:43 ` cvs-commit at gcc dot gnu.org
  2020-12-19 12:46 ` ssbssa at sourceware dot org
  2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-12-19 12:43 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #1 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Hannes Domani <ssbssa@sourceware.org>:

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

commit fa639f555afbe6bf670c27d161c42974740987cb
Author: Hannes Domani <ssbssa@yahoo.de>
Date:   Mon Dec 14 19:06:38 2020 +0100

    Don't compare types of enum fields

    Comparing types of enum fields results in a crash, because they don't
    have a type.

    It can be reproduced by comparing the types of 2 instances of the same
    enum type in different objects:

    enum.h:

        enum e
        {
          zero,
          one,
        };

    enum-1.c:

        #include <enum.h>
        int func();
        enum e e1;
        int main()
        {
          return e1 + func();
        }

    enum-2.c:

        #include <enum.h>
        enum e e2;
        int func()
        {
          return e2;
        }

    $ gcc -g -oenum enum-1.c enum-2.c
    $ gdb -q enum.exe
    Reading symbols from enum.exe...
    (gdb) py
print(gdb.parse_and_eval("e1").type==gdb.parse_and_eval("e2").type)

    Thread 1 received signal SIGSEGV, Segmentation fault.
    [Switching to Thread 6184.0x1cc4]
    check_typedef (type=0x0) at
C:/src/repos/binutils-gdb.git/gdb/gdbtypes.c:2745
    2745      while (type->code () == TYPE_CODE_TYPEDEF)

    gdb/ChangeLog:

    2020-12-19  Hannes Domani  <ssbssa@yahoo.de>

            PR exp/27070
            * gdbtypes.c (check_types_equal): Don't compare types of enum
fields.

    gdb/testsuite/ChangeLog:

    2020-12-19  Hannes Domani  <ssbssa@yahoo.de>

            PR exp/27070
            * gdb.python/compare-enum-type-a.c: New test.
            * gdb.python/compare-enum-type-b.c: New test.
            * gdb.python/compare-enum-type.exp: New file.
            * gdb.python/compare-enum-type.h: New test.

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

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

* [Bug exp/27070] gdb crashes when comparing 2 instances of the same enum
  2020-12-14 17:01 [Bug exp/27070] New: gdb crashes when comparing 2 instances of the same enum ssbssa at sourceware dot org
  2020-12-14 18:14 ` [Bug exp/27070] " ssbssa at sourceware dot org
  2020-12-19 12:43 ` cvs-commit at gcc dot gnu.org
@ 2020-12-19 12:46 ` ssbssa at sourceware dot org
  2 siblings, 0 replies; 4+ messages in thread
From: ssbssa at sourceware dot org @ 2020-12-19 12:46 UTC (permalink / raw)
  To: gdb-prs

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

Hannes Domani <ssbssa at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
   Target Milestone|---                         |11.1
             Status|NEW                         |RESOLVED

--- Comment #2 from Hannes Domani <ssbssa at sourceware dot org> ---
Fixed.

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

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

end of thread, other threads:[~2020-12-19 12:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-14 17:01 [Bug exp/27070] New: gdb crashes when comparing 2 instances of the same enum ssbssa at sourceware dot org
2020-12-14 18:14 ` [Bug exp/27070] " ssbssa at sourceware dot org
2020-12-19 12:43 ` cvs-commit at gcc dot gnu.org
2020-12-19 12:46 ` ssbssa at sourceware dot 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).