Bug 20630

Summary: gdb crash from TYPE_OBJFILE_OWNED
Product: gdb Reporter: Tom Tromey <tromey>
Component: expAssignee: Tom Tromey <tromey>
Status: RESOLVED FIXED    
Severity: normal CC: arnez, bioloidgp, jankowski938, rikard.falkeborn
Priority: P2    
Version: HEAD   
Target Milestone: 13.1   
Host: Target:
Build: Last reconfirmed:

Description Tom Tromey 2016-09-23 14:11:55 UTC
I found a simple way to crash gdb:

$ /bin/gdb -nx /bin/gdb
(gdb) start
(gdb) p ({unsigned char[]}{0x17})
../../gdb/gdbtypes.c:4641: 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 1 Hannes Domani 2020-04-11 11:21:18 UTC
*** Bug 21162 has been marked as a duplicate of this bug. ***
Comment 2 Tom Tromey 2022-06-05 17:24:33 UTC
*** Bug 20760 has been marked as a duplicate of this bug. ***
Comment 3 Tom Tromey 2022-06-05 17:25:10 UTC
*** Bug 25209 has been marked as a duplicate of this bug. ***
Comment 4 Tom Tromey 2022-06-05 17:30:49 UTC
Sent a patch.
Comment 5 Sourceware Commits 2022-06-18 16:43:52 UTC
The master branch has been updated by Tom Tromey <tromey@sourceware.org>:

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

commit 8e2da165187907a570a33eee7e56ce16fc597a40
Author: Tom Tromey <tom@tromey.com>
Date:   Sun Jun 5 11:28:10 2022 -0600

    Fix assertion failure in copy_type
    
    PR exp/20630 points out a simple way to cause an assertion failure in
    copy_type -- but this was found in the wild a few times as well.
    
    copy_type only works for objfile-owned types, but there isn't a deep
    reason for this.  This patch fixes the bug by updating copy_type to
    work for any sort of type.
    
    Better would perhaps be to finally implement type GC, but I still
    haven't attempted this.
    
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=20630
Comment 6 Tom Tromey 2022-06-18 16:45:52 UTC
Fixed.
Comment 7 Tom Tromey 2023-03-17 13:55:02 UTC
*** Bug 30238 has been marked as a duplicate of this bug. ***