Bug 21162

Summary: GDB internal error with unbounded array typecast expression
Product: gdb Reporter: Andreas Arnez <arnez>
Component: expAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED DUPLICATE    
Severity: normal CC: brobecker, qiyao, ssbssa
Priority: P2    
Version: HEAD   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:
Attachments: Test case for internal error with unbounded array typecast

Description Andreas Arnez 2017-02-14 17:30:33 UTC
GDB crashes with internal error when trying to evaluate the following expression:

(gdb) p ((char*)(short[]){1})[1]
/home/arnez/src/binutils-gdb/gdb/gdbtypes.c:4722: internal-error: type* copy_type(const type*): Assertion `TYPE_OBJFILE_OWNED (type)' failed.
Comment 1 Joel Brobecker 2017-02-15 03:27:13 UTC
Is this a regression compared to 7.12?
Comment 2 Yao Qi 2017-02-15 08:51:34 UTC
(In reply to Joel Brobecker from comment #1)
> Is this a regression compared to 7.12?

No, 7.12.1 and 7.11.1 fails too.

(gdb) run
Starting program: /home/qiyao/source/gdb-7.11/build-7.11.1/gdb/gdb 

Breakpoint 1, main (argc=1, argv=0x7fffffffe648) at ../../gdb-7.11.1/gdb/gdb.c:25
25	{
(gdb) p ((char*)(short[]){1})[1]
Python Exception <type 'exceptions.NameError'> Installation error: gdb.execute_unwinders function is missing: 
../../gdb-7.11.1/gdb/gdbtypes.c:4575: internal-error: copy_type: Assertion `TYPE_OBJFILE_OWNED (type)' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)
Comment 3 Joel Brobecker 2017-02-16 03:08:23 UTC
Thanks for confirming, Yao. So this PR should not be blocking for 8.0, and I will remove the target milestone. Of course, we still have plenty of time until branching and eventually release, so if it gets fixed by then, all the better!
Comment 4 Andreas Arnez 2017-02-16 18:00:35 UTC
This problem was introduced in April 2014 with GIT commit 80180f796d366d230822c07a15aa68971abf9d77 -- "type: add c99 variable length array support" (https://sourceware.org/ml/gdb-patches/2014-04/msg00160.html).
Comment 5 Andreas Arnez 2017-02-16 18:09:10 UTC
Created attachment 9832 [details]
Test case for internal error with unbounded array typecast
Comment 6 Hannes Domani 2020-04-10 00:23:34 UTC
I think this is a duplicate of PR20630.
Comment 7 Hannes Domani 2020-04-11 11:21:18 UTC
Dup.

*** This bug has been marked as a duplicate of bug 20630 ***