public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug compile/31508] New: compile not working for some programs
@ 2024-03-19  7:35 tsqurt at outlook dot com
  2024-03-24 11:07 ` [Bug compile/31508] " tsqurt at outlook dot com
  2024-03-24 17:20 ` tromey at sourceware dot org
  0 siblings, 2 replies; 3+ messages in thread
From: tsqurt at outlook dot com @ 2024-03-19  7:35 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 31508
           Summary: compile not working for some programs
           Product: gdb
           Version: 15.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: compile
          Assignee: unassigned at sourceware dot org
          Reporter: tsqurt at outlook dot com
  Target Milestone: ---

```
int main ()
{
  int n = 2;
  struct S
  {
    int i[n];
  };

  struct S s[3];
  s[0].i[0] = 0;
  return 0;
}
```
The `expr` command fails even for trivial cases.

```
gcc src.c -g && gdb a.out
(gdb) b 11
Breakpoint 1 at 0x12f0: file src.c, line 11.
(gdb) run
Starting program: a.out 

Breakpoint 1, main () at src.c:11
11        return 0;
(gdb) expr 1
/tmp/gdbobj-YZnp7a/out1.c:50:43: error: redeclaration of
‘__gdb_prop_0x5565ba93ba70’ with no linkage
   50 |   __attribute__ ((unused)) unsigned long  __gdb_prop_0x5565ba93ba70;
      |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/gdbobj-YZnp7a/out1.c:30:43: note: previous declaration of
‘__gdb_prop_0x5565ba93ba70’ was here
   30 |   __attribute__ ((unused)) unsigned long  __gdb_prop_0x5565ba93ba70;
      |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~
Compilation failed.
```

Version:
gcc (GCC) 14.0.1 20240312 (experimental)
GNU gdb (GDB) 15.0.50.20240313-git

Platform:
ubuntu 20.04 LTS

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

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

* [Bug compile/31508] compile not working for some programs
  2024-03-19  7:35 [Bug compile/31508] New: compile not working for some programs tsqurt at outlook dot com
@ 2024-03-24 11:07 ` tsqurt at outlook dot com
  2024-03-24 17:20 ` tromey at sourceware dot org
  1 sibling, 0 replies; 3+ messages in thread
From: tsqurt at outlook dot com @ 2024-03-24 11:07 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #1 from Tan Senqi <tsqurt at outlook dot com> ---
A new test case to be added, which triggers a segmentation fault:

void break_point() {}
void foo(int n)
{
  struct S {
    int i[n];
    unsigned int b:1;
    int i2;
  } __attribute__ ((packed)) __attribute__ ((aligned (4)));

  struct S s;


break_point();; // break here and run; then command `expr s.i2 = 0`
}

int main(void)
{
  foo(4);

  return 0;
}



(gdb) expr s.i2=0
/tmp/gdbobj-FjNhCp/out1.c:50:43: error: redeclaration of ‘__gdb_prop_0x17c22c0’
with no linkage
   50 |   __attribute__ ((unused)) unsigned long  __gdb_prop_0x17c22c0;
      |                                           ^~~~~~~~~~~~~~~~~~~~
/tmp/gdbobj-FjNhCp/out1.c:30:43: note: previous declaration of
‘__gdb_prop_0x17c22c0’ with type ‘long unsigned int’
   30 |   __attribute__ ((unused)) unsigned long  __gdb_prop_0x17c22c0;
      |                                           ^~~~~~~~~~~~~~~~~~~~
../../binutils-gdb/gdb/gdbtypes.h:627: internal-error: loc_bitpos: Assertion
`m_loc_kind == FIELD_LOC_KIND_BITPOS' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
----- Backtrace -----
0x4e81b2 gdb_internal_backtrace_1
        ../../binutils-gdb/gdb/bt-utils.c:122
0x4e81b2 _Z22gdb_internal_backtracev
        ../../binutils-gdb/gdb/bt-utils.c:168
0x8adea4 internal_vproblem
        ../../binutils-gdb/gdb/utils.c:421
0x8ae208 _Z15internal_verrorPKciS0_P13__va_list_tag
        ../../binutils-gdb/gdb/utils.c:501
0x9f9e31 _Z18internal_error_locPKciS0_z
        ../../binutils-gdb/gdbsupport/errors.cc:58
0x5324f8 _ZNK5field10loc_bitposEv
        ../../binutils-gdb/gdb/gdbtypes.h:627
0x5324f8 _ZNK5field10loc_bitposEv
        ../../binutils-gdb/gdb/gdbtypes.h:625
0x5324f8 convert_struct_or_union
        ../../binutils-gdb/gdb/compile/compile-c-types.c:118
0x5324f8 convert_type_basic
        ../../binutils-gdb/gdb/compile/compile-c-types.c:297
0x5324f8 _ZN18compile_c_instance12convert_typeEP4type
        ../../binutils-gdb/gdb/compile/compile-c-types.c:357
0x53138b convert_one_symbol
        ../../binutils-gdb/gdb/compile/compile-c-symbols.c:68
0x531a0d convert_symbol_sym
        ../../binutils-gdb/gdb/compile/compile-c-symbols.c:256
0x531a0d _Z18gcc_convert_symbolPvP13gcc_c_context20gcc_c_oracle_requestPKc
        ../../binutils-gdb/gdb/compile/compile-c-symbols.c:355
0x7f8fdcd399e7 c_call_binding_oracle
        ../../gcc/libcc1/libcc1.cc:79
0x7f8fdcd399e7 call<2, (anonymous namespace)::c_call_binding_oracle,
gcc_c_oracle_request, char const*>
        ../../gcc/libcc1/libcc1.cc:148
0x7f8fdcd399e7 call<1, (anonymous namespace)::c_call_binding_oracle,
gcc_c_oracle_request>
        ../../gcc/libcc1/rpc.hh:162
0x7f8fdcd399e7 call<0, (anonymous namespace)::c_call_binding_oracle>
        ../../gcc/libcc1/rpc.hh:162
0x7f8fdcd399e7 invoke<(anonymous namespace)::c_call_binding_oracle>
        ../../gcc/libcc1/rpc.hh:181
0x7f8fdcd43071 _ZN10cc1_plugin10connection7do_waitEb
        ../../gcc/libcc1/connection.cc:135
0x7f8fdcd3c70b _ZN10cc1_plugin10connection14wait_for_queryEv
        ../../gcc/libcc1/connection.hh:82
0x7f8fdcd3c70b
_ZN10cc1_plugin15base_gdb_pluginI13gcc_c_contextE9fork_execEPPcPiS5_
        ../../gcc/libcc1/gdbctx.hh:248
0x7f8fdcd3c70b
_ZN10cc1_plugin15base_gdb_pluginI13gcc_c_contextE10do_compileEP16gcc_base_contextPKc
        ../../gcc/libcc1/gdbctx.hh:315
0x541823 _ZN16compile_instance7compileEPKci
        ../../binutils-gdb/gdb/compile/compile.c:942
0x542333 compile_to_object
        ../../binutils-gdb/gdb/compile/compile.c:788
0x542333 _Z20eval_compile_commandP12command_linePKc21compile_i_scope_typesPv
        ../../binutils-gdb/gdb/compile/compile.c:817
0x5433bb compile_code_command
        ../../binutils-gdb/gdb/compile/compile.c:356
0x51b6f4 _Z8cmd_funcP16cmd_list_elementPKci
        ../../binutils-gdb/gdb/cli/cli-decode.c:2742
0x8438b6 _Z15execute_commandPKci
        ../../binutils-gdb/gdb/top.c:571
0x5f2f7f _Z15command_handlerPKc
        ../../binutils-gdb/gdb/event-top.c:567
0x5f450a _Z20command_line_handlerOSt10unique_ptrIcN3gdb13xfree_deleterIcEEE
        ../../binutils-gdb/gdb/event-top.c:803
0x5f378c gdb_rl_callback_handler
        ../../binutils-gdb/gdb/event-top.c:259
0x8f42a4 rl_callback_read_char
        ../../../binutils-gdb/readline/readline/callback.c:290
0x5f38ad gdb_rl_callback_read_char_wrapper_noexcept
        ../../binutils-gdb/gdb/event-top.c:195
0x5f3a2c gdb_rl_callback_read_char_wrapper
        ../../binutils-gdb/gdb/event-top.c:234
0x87e47f stdin_event_handler
        ../../binutils-gdb/gdb/ui.c:155
0x9faa45 gdb_wait_for_event
        ../../binutils-gdb/gdbsupport/event-loop.cc:716
0x9fb221 _Z16gdb_do_one_eventi
        ../../binutils-gdb/gdbsupport/event-loop.cc:264
0x6bcee9 start_event_loop
        ../../binutils-gdb/gdb/main.c:401
0x6bcee9 captured_command_loop
        ../../binutils-gdb/gdb/main.c:465
0x6bfa14 captured_main
        ../../binutils-gdb/gdb/main.c:1339
0x6bfa14 _Z8gdb_mainP18captured_main_args
        ../../binutils-gdb/gdb/main.c:1358
0x444d54 main
        ../../binutils-gdb/gdb/gdb.c:39
---------------------
../../binutils-gdb/gdb/gdbtypes.h:627: internal-error: loc_bitpos: Assertion
`m_loc_kind == FIELD_LOC_KIND_BITPOS' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)  y
Please answer y or n.
../../binutils-gdb/gdb/gdbtypes.h:627: internal-error: loc_bitpos: Assertion
`m_loc_kind == FIELD_LOC_KIND_BITPOS' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) n

This is a bug, please report it.  For instructions, see:
<https://www.gnu.org/software/gdb/bugs/>.

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

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

* [Bug compile/31508] compile not working for some programs
  2024-03-19  7:35 [Bug compile/31508] New: compile not working for some programs tsqurt at outlook dot com
  2024-03-24 11:07 ` [Bug compile/31508] " tsqurt at outlook dot com
@ 2024-03-24 17:20 ` tromey at sourceware dot org
  1 sibling, 0 replies; 3+ messages in thread
From: tromey at sourceware dot org @ 2024-03-24 17:20 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at sourceware dot org> changed:

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

--- Comment #2 from Tom Tromey <tromey at sourceware dot org> ---
That second test case is pretty weird.
I think that sort of VLA is a GNU extension, I tend to
doubt it exists in real code anywhere.
I wonder if gdb's "print" can even handle it (didn't try yet).

Anyway I wonder if it's sufficient to translate these into
non-VLAs for the purposes of 'compile'.

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

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

end of thread, other threads:[~2024-03-24 17:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-19  7:35 [Bug compile/31508] New: compile not working for some programs tsqurt at outlook dot com
2024-03-24 11:07 ` [Bug compile/31508] " tsqurt at outlook dot com
2024-03-24 17:20 ` tromey 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).