public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "ssbssa at sourceware dot org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug exp/27070] New: gdb crashes when comparing 2 instances of the same enum
Date: Mon, 14 Dec 2020 17:01:39 +0000	[thread overview]
Message-ID: <bug-27070-4717@http.sourceware.org/bugzilla/> (raw)

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.

             reply	other threads:[~2020-12-14 17:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-14 17:01 ssbssa at sourceware dot org [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-27070-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).