public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libcc1/114389] New: internal compiler error when compiling nested structure in gdb
@ 2024-03-19  7:21 tsqurt at outlook dot com
  2024-04-01  6:53 ` [Bug libcc1/114389] internal compiler error when compiling structure field with name-conflict in gdb `command` tsqurt at outlook dot com
  0 siblings, 1 reply; 2+ messages in thread
From: tsqurt at outlook dot com @ 2024-03-19  7:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114389

            Bug ID: 114389
           Summary: internal compiler error when compiling nested
                    structure in gdb
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libcc1
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tsqurt at outlook dot com
  Target Milestone: ---

```
struct foo { int loc1; } bar;

int main()
{
    bar.loc1 = 0; // break here
    return 0;
}
```
Compile and start debugging with command gcc src.c -g && gdb a.out. 

```
(gdb) b 5
Breakpoint 1 at 0x40110a: file src.c, line 5.
(gdb) run
Starting program: a.out 

Breakpoint 1, main () at src.c:5
5           bar.loc1 = 0;
(gdb) expr bar.loc1
warning: variable has unknown type; assuming int
gdb command line:1:4: warning: statement with no effect [-Wunused-value]
*** WARNING *** there are active plugins, do not report this as a bug unless
you can reproduce it without enabling any plugins.
Event                            | Plugins
PLUGIN_PRE_GENERICIZE            | libcc1plugin
PLUGIN_GGC_MARKING               | libcc1plugin
PLUGIN_PRAGMAS                   | libcc1plugin
gdb command line:1:4: internal compiler error: tree check: expected field_decl,
have indirect_ref in component_ref_field_offset, at tree.cc:13095
0x866436 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ../../gcc/gcc/tree.cc:8955
0x86ea64 tree_check(tree_node*, char const*, int, char const*, tree_code)
        ../../gcc/gcc/tree.h:3612
0x86ea64 component_ref_field_offset(tree_node*)
        ../../gcc/gcc/tree.cc:13095
0xd08225 gimplify_compound_lval
        ../../gcc/gcc/gimplify.cc:3483
0xcff389 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gcc/gimplify.cc:17740
0xd01de6 gimplify_stmt(tree_node**, gimple**)
        ../../gcc/gcc/gimplify.cc:7485
0xd02ee6 gimplify_bind_expr
        ../../gcc/gcc/gimplify.cc:1619
0xcffad4 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gcc/gimplify.cc:17992
0xd16e05 gimplify_stmt(tree_node**, gimple**)
        ../../gcc/gcc/gimplify.cc:7485
0xd16e05 gimplify_body(tree_node*, bool)
        ../../gcc/gcc/gimplify.cc:19058
0xd1724c gimplify_function_tree(tree_node*)
        ../../gcc/gcc/gimplify.cc:19257
0xb3abf7 cgraph_node::analyze()
        ../../gcc/gcc/cgraphunit.cc:687
0xb3d757 analyze_functions
        ../../gcc/gcc/cgraphunit.cc:1251
0xb3e6dd symbol_table::finalize_compilation_unit()
        ../../gcc/gcc/cgraphunit.cc:2558
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compilation failed.
```

Platform: x86-64, Ubuntu 20.04
Affected GCC: gcc-trunk, gcc-13.2.0, gcc-9.4.0.
Affected GDB: gdb-trunk, gdb-12.1, gdb-9.1.

Note: Version gcc-13.2.0 and below will trigger a segmentation fault, rather
than internal compiler error.
In this case, the member name text "loc1" is a must to trigger internal
compiler error.
Note: Alternative text "buf" for gdb-9.1, and "once" for gdb-12.1. 


A similar test case when handling the same name of "bar" twice:

```
struct foo { int bar; } * bar;

int main()
{
  struct foo x;
  x.bar = 0; // break here
  return 0;
}
```

```
(gdb) b 6
Breakpoint 1 at 0x40110a: file src2.c, line 6.
(gdb) run
Starting program: /home/asahi/emd/bugs/b/a.out 

Breakpoint 1, main () at src2.c:6
6         x.bar = 0;
(gdb) expr x.bar
gdb command line:1:2: warning: statement with no effect [-Wunused-value]
*** WARNING *** there are active plugins, do not report this as a bug unless
you can reproduce it without enabling any plugins.
Event                            | Plugins
PLUGIN_PRE_GENERICIZE            | libcc1plugin
PLUGIN_GGC_MARKING               | libcc1plugin
PLUGIN_PRAGMAS                   | libcc1plugin
gdb command line:1:2: internal compiler error: tree check: expected field_decl,
have indirect_ref in component_ref_field_offset, at tree.cc:13095
0x866436 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ../../gcc/gcc/tree.cc:8955
0x86ea64 tree_check(tree_node*, char const*, int, char const*, tree_code)
        ../../gcc/gcc/tree.h:3612
0x86ea64 component_ref_field_offset(tree_node*)
        ../../gcc/gcc/tree.cc:13095
0xd08225 gimplify_compound_lval
        ../../gcc/gcc/gimplify.cc:3483
0xcff389 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gcc/gimplify.cc:17740
0xd01de6 gimplify_stmt(tree_node**, gimple**)
        ../../gcc/gcc/gimplify.cc:7485
0xd0089b gimplify_statement_list
        ../../gcc/gcc/gimplify.cc:2227
0xd0089b gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gcc/gimplify.cc:18236
0xd01de6 gimplify_stmt(tree_node**, gimple**)
        ../../gcc/gcc/gimplify.cc:7485
0xd02ee6 gimplify_bind_expr
        ../../gcc/gcc/gimplify.cc:1619
0xcffad4 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gcc/gimplify.cc:17992
0xd16e05 gimplify_stmt(tree_node**, gimple**)
        ../../gcc/gcc/gimplify.cc:7485
0xd16e05 gimplify_body(tree_node*, bool)
        ../../gcc/gcc/gimplify.cc:19058
0xd1724c gimplify_function_tree(tree_node*)
        ../../gcc/gcc/gimplify.cc:19257
0xb3abf7 cgraph_node::analyze()
        ../../gcc/gcc/cgraphunit.cc:687
0xb3d757 analyze_functions
        ../../gcc/gcc/cgraphunit.cc:1251
0xb3e6dd symbol_table::finalize_compilation_unit()
        ../../gcc/gcc/cgraphunit.cc:2558
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compilation failed.
```

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

* [Bug libcc1/114389] internal compiler error when compiling structure field with name-conflict in gdb `command`
  2024-03-19  7:21 [Bug libcc1/114389] New: internal compiler error when compiling nested structure in gdb tsqurt at outlook dot com
@ 2024-04-01  6:53 ` tsqurt at outlook dot com
  0 siblings, 0 replies; 2+ messages in thread
From: tsqurt at outlook dot com @ 2024-04-01  6:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114389

--- Comment #1 from Tan Senqi <tsqurt at outlook dot com> ---
reconfirmed at 2024-4-1
GCC: gcc (GCC) 14.0.1 20240401 (experimental)
GDB: GNU gdb (GDB) 14.2
Platform: AMD64, ubuntu 20.04
Testcase is following; Note that the position where segmentation fault happens
is different in this version().

struct A { int a;} a;

int main ()
{
  struct A r;
  r.a = 0;
  return 0;
}

(gdb) b 6
Breakpoint 1 at 0x40110a: file a.c, line 6.
(gdb) run
Starting program: /home/asahi/emd/build/a.out

Breakpoint 1, main () at a.c:6
6         r.a = 0;
(gdb) expr r.a = 0
*** WARNING *** there are active plugins, do not report this as a bug unless
you can reproduce it without enabling any plugins.
Event                            | Plugins
PLUGIN_PRE_GENERICIZE            | libcc1plugin
PLUGIN_GGC_MARKING               | libcc1plugin
PLUGIN_PRAGMAS                   | libcc1plugin
gdb command line:1:2: internal compiler error: Segmentation fault
0xc402bf crash_signal
        ../.././gcc/toplev.cc:314
0x7f71bf63708f ???
       
/build/glibc-wuryBv/glibc-2.31/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0xebedc2 component_ref_field_offset(tree_node*)
        ../.././gcc/tree.cc:12990
0x9afd62 gimplify_compound_lval
        ../.././gcc/gimplify.cc:3250
0x9aa537 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../.././gcc/gimplify.cc:16335
0x9b660a gimplify_modify_expr
        ../.././gcc/gimplify.cc:6169
0x9aab9d gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../.././gcc/gimplify.cc:16383
0x9ac415 gimplify_stmt(tree_node**, gimple**)
        ../.././gcc/gimplify.cc:7226
0x9ac415 gimplify_statement_list
        ../.././gcc/gimplify.cc:2019
0x9ac415 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../.././gcc/gimplify.cc:16828
0x9b22fd gimplify_stmt(tree_node**, gimple**)
        ../.././gcc/gimplify.cc:7226
0x9b22fd gimplify_bind_expr
        ../.././gcc/gimplify.cc:1430
0x9ab52a gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../.././gcc/gimplify.cc:16584
0x9aef13 gimplify_stmt(tree_node**, gimple**)
        ../.././gcc/gimplify.cc:7226
0x9aef13 gimplify_body(tree_node*, bool)
        ../.././gcc/gimplify.cc:17645
0x9af2d2 gimplify_function_tree(tree_node*)
        ../.././gcc/gimplify.cc:17844
0x83bf57 cgraph_node::analyze()
        ../.././gcc/cgraphunit.cc:684
0x83e567 analyze_functions
        ../.././gcc/cgraphunit.cc:1247
0x83f18d symbol_table::finalize_compilation_unit()
        ../.././gcc/cgraphunit.cc:2554
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compilation failed.

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

end of thread, other threads:[~2024-04-01  6:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-19  7:21 [Bug libcc1/114389] New: internal compiler error when compiling nested structure in gdb tsqurt at outlook dot com
2024-04-01  6:53 ` [Bug libcc1/114389] internal compiler error when compiling structure field with name-conflict in gdb `command` tsqurt at outlook dot com

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).