* [PATCH][gdb/symtab] Fix assert in write_one_signatured_type
@ 2021-02-01 14:43 Tom de Vries
2021-02-01 16:16 ` Simon Marchi
0 siblings, 1 reply; 3+ messages in thread
From: Tom de Vries @ 2021-02-01 14:43 UTC (permalink / raw)
To: gdb-patches
Hi,
When running test-case gdb.dwarf2/fission-reread.exp with target board
cc-with-gdb-index, we run into an abort during the generation of the gdb-index
by cc-with-tweaks.sh:
...
build/gdb/testsuite/cache/gdb.sh: line 1: 27275 Aborted (core dumped)
...
This can be reproduced on the command line like this:
...
$ gdb -batch ./outputs/gdb.dwarf2/fission-reread/fission-reread \
-ex 'save gdb-index ./outputs/gdb.dwarf2/fission-reread'
warning: Could not find DWO TU fission-reread.dwo(0x9022f1ceac7e8b19) \
referenced by TU at offset 0x0 [in module fission-reread]
warning: Could not find DWO CU fission-reread.dwo(0x807060504030201) \
referenced by CU at offset 0x561 [in module fission-reread]
Aborted (core dumped)
...
The abort is a segfault due to a using a nullptr psymtab in
write_one_signatured_type.
The problem is that we're trying to write index entries for the type unit
with signature:
...
(gdb) p /x entry->signature
$2 = 0x9022f1ceac7e8b19
...
which is a skeleton type unit:
...
Contents of the .debug_types section:
Compilation Unit @ offset 0x0:
Length: 0x4a (32-bit)
Version: 4
Abbrev Offset: 0x165
Pointer Size: 4
Signature: 0x9022f1ceac7e8b19
Type Offset: 0x0
<0><17>: Abbrev Number: 2 (DW_TAG_type_unit)
<18> DW_AT_comp_dir : /tmp/src/gdb/testsuite
<2f> DW_AT_GNU_dwo_name: fission-reread.dwo
<42> DW_AT_GNU_pubnames: 0x0
<46> DW_AT_GNU_pubtypes: 0x0
<4a> DW_AT_GNU_addr_base: 0x0
...
referring to a .dwo file, but as the warnings show, the .dwo file is not
found.
Fix this by skipping the type unit in write_one_signatured_type if
psymtab == nullptr.
Tested on x86_64-linux.
Any comments?
Thanks,
- Tom
[gdb/symtab] Fix assert in write_one_signatured_type
gdb/ChangeLog:
2021-02-01 Tom de Vries <tdevries@suse.de>
PR symtab/24620
* dwarf2/index-write.c (write_one_signatured_type): Skip if
psymtab == nullptr.
---
gdb/dwarf2/index-write.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
index 66781feaf46..a7b9ae66cae 100644
--- a/gdb/dwarf2/index-write.c
+++ b/gdb/dwarf2/index-write.c
@@ -616,6 +616,14 @@ write_one_signatured_type (void **slot, void *d)
struct signatured_type *entry = (struct signatured_type *) *slot;
partial_symtab *psymtab = entry->per_cu.v.psymtab;
+ if (psymtab == nullptr)
+ {
+ /* We can end up here when processing a skeleton CU referring to a
+ .dwo file that hasn't been found. There's not much we can do in
+ such a case, so skip this CU. */
+ return 1;
+ }
+
write_psymbols (info->symtab, info->psyms_seen,
psymtab->global_psymbols, info->cu_index,
0);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH][gdb/symtab] Fix assert in write_one_signatured_type
2021-02-01 14:43 [PATCH][gdb/symtab] Fix assert in write_one_signatured_type Tom de Vries
@ 2021-02-01 16:16 ` Simon Marchi
2021-02-02 8:34 ` Tom de Vries
0 siblings, 1 reply; 3+ messages in thread
From: Simon Marchi @ 2021-02-01 16:16 UTC (permalink / raw)
To: Tom de Vries, gdb-patches
On 2021-02-01 9:43 a.m., Tom de Vries wrote:> Hi,
>
> When running test-case gdb.dwarf2/fission-reread.exp with target board
> cc-with-gdb-index, we run into an abort during the generation of the gdb-index
> by cc-with-tweaks.sh:
> ...
> build/gdb/testsuite/cache/gdb.sh: line 1: 27275 Aborted (core dumped)
> ...
>
> This can be reproduced on the command line like this:
> ...
> $ gdb -batch ./outputs/gdb.dwarf2/fission-reread/fission-reread \
> -ex 'save gdb-index ./outputs/gdb.dwarf2/fission-reread'
> warning: Could not find DWO TU fission-reread.dwo(0x9022f1ceac7e8b19) \
> referenced by TU at offset 0x0 [in module fission-reread]
> warning: Could not find DWO CU fission-reread.dwo(0x807060504030201) \
> referenced by CU at offset 0x561 [in module fission-reread]
> Aborted (core dumped)
> ...
>
> The abort is a segfault due to a using a nullptr psymtab in
> write_one_signatured_type.
>
> The problem is that we're trying to write index entries for the type unit
> with signature:
> ...
> (gdb) p /x entry->signature
> $2 = 0x9022f1ceac7e8b19
> ...
> which is a skeleton type unit:
> ...
> Contents of the .debug_types section:
>
> Compilation Unit @ offset 0x0:
> Length: 0x4a (32-bit)
> Version: 4
> Abbrev Offset: 0x165
> Pointer Size: 4
> Signature: 0x9022f1ceac7e8b19
> Type Offset: 0x0
> <0><17>: Abbrev Number: 2 (DW_TAG_type_unit)
> <18> DW_AT_comp_dir : /tmp/src/gdb/testsuite
> <2f> DW_AT_GNU_dwo_name: fission-reread.dwo
> <42> DW_AT_GNU_pubnames: 0x0
> <46> DW_AT_GNU_pubtypes: 0x0
> <4a> DW_AT_GNU_addr_base: 0x0
> ...
> referring to a .dwo file, but as the warnings show, the .dwo file is not
> found.
>
> Fix this by skipping the type unit in write_one_signatured_type if
> psymtab == nullptr.
>
> Tested on x86_64-linux.
>
> Any comments?
>
> Thanks,
> - Tom
>
> [gdb/symtab] Fix assert in write_one_signatured_type
>
> gdb/ChangeLog:
>
> 2021-02-01 Tom de Vries <tdevries@suse.de>
>
> PR symtab/24620
> * dwarf2/index-write.c (write_one_signatured_type): Skip if
> psymtab == nullptr.
>
> ---
> gdb/dwarf2/index-write.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
> index 66781feaf46..a7b9ae66cae 100644
> --- a/gdb/dwarf2/index-write.c
> +++ b/gdb/dwarf2/index-write.c
> @@ -616,6 +616,14 @@ write_one_signatured_type (void **slot, void *d)
> struct signatured_type *entry = (struct signatured_type *) *slot;
> partial_symtab *psymtab = entry->per_cu.v.psymtab;
>
> + if (psymtab == nullptr)
> + {
> + /* We can end up here when processing a skeleton CU referring to a
> + .dwo file that hasn't been found. There's not much we can do in
> + such a case, so skip this CU. */
> + return 1;
> + }
> +
> write_psymbols (info->symtab, info->psyms_seen,
> psymtab->global_psymbols, info->cu_index,
> 0);
>
LGTM, some questions:
1. Do we need to emit a warning here? Probably not because another one
should have been emitted earlier, when parsing symbols. But I thought
I'd ask just in case.
2. Would it be somewhat easy to write a test for this? Have a type unit
with a dwo, delete the dwo, try to generate an index.
3. Is the same situation correctly handled for standard compile units?
Simon
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH][gdb/symtab] Fix assert in write_one_signatured_type
2021-02-01 16:16 ` Simon Marchi
@ 2021-02-02 8:34 ` Tom de Vries
0 siblings, 0 replies; 3+ messages in thread
From: Tom de Vries @ 2021-02-02 8:34 UTC (permalink / raw)
To: Simon Marchi, gdb-patches
On 2/1/21 5:16 PM, Simon Marchi wrote:
> On 2021-02-01 9:43 a.m., Tom de Vries wrote:> Hi,
>>
>> When running test-case gdb.dwarf2/fission-reread.exp with target board
>> cc-with-gdb-index, we run into an abort during the generation of the gdb-index
>> by cc-with-tweaks.sh:
>> ...
>> build/gdb/testsuite/cache/gdb.sh: line 1: 27275 Aborted (core dumped)
>> ...
>>
>> This can be reproduced on the command line like this:
>> ...
>> $ gdb -batch ./outputs/gdb.dwarf2/fission-reread/fission-reread \
>> -ex 'save gdb-index ./outputs/gdb.dwarf2/fission-reread'
>> warning: Could not find DWO TU fission-reread.dwo(0x9022f1ceac7e8b19) \
>> referenced by TU at offset 0x0 [in module fission-reread]
>> warning: Could not find DWO CU fission-reread.dwo(0x807060504030201) \
>> referenced by CU at offset 0x561 [in module fission-reread]
>> Aborted (core dumped)
>> ...
>>
>> The abort is a segfault due to a using a nullptr psymtab in
>> write_one_signatured_type.
>>
>> The problem is that we're trying to write index entries for the type unit
>> with signature:
>> ...
>> (gdb) p /x entry->signature
>> $2 = 0x9022f1ceac7e8b19
>> ...
>> which is a skeleton type unit:
>> ...
>> Contents of the .debug_types section:
>>
>> Compilation Unit @ offset 0x0:
>> Length: 0x4a (32-bit)
>> Version: 4
>> Abbrev Offset: 0x165
>> Pointer Size: 4
>> Signature: 0x9022f1ceac7e8b19
>> Type Offset: 0x0
>> <0><17>: Abbrev Number: 2 (DW_TAG_type_unit)
>> <18> DW_AT_comp_dir : /tmp/src/gdb/testsuite
>> <2f> DW_AT_GNU_dwo_name: fission-reread.dwo
>> <42> DW_AT_GNU_pubnames: 0x0
>> <46> DW_AT_GNU_pubtypes: 0x0
>> <4a> DW_AT_GNU_addr_base: 0x0
>> ...
>> referring to a .dwo file, but as the warnings show, the .dwo file is not
>> found.
>>
>> Fix this by skipping the type unit in write_one_signatured_type if
>> psymtab == nullptr.
>>
>> Tested on x86_64-linux.
>>
>> Any comments?
>>
>> Thanks,
>> - Tom
>>
>> [gdb/symtab] Fix assert in write_one_signatured_type
>>
>> gdb/ChangeLog:
>>
>> 2021-02-01 Tom de Vries <tdevries@suse.de>
>>
>> PR symtab/24620
>> * dwarf2/index-write.c (write_one_signatured_type): Skip if
>> psymtab == nullptr.
>>
>> ---
>> gdb/dwarf2/index-write.c | 8 ++++++++
>> 1 file changed, 8 insertions(+)
>>
>> diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
>> index 66781feaf46..a7b9ae66cae 100644
>> --- a/gdb/dwarf2/index-write.c
>> +++ b/gdb/dwarf2/index-write.c
>> @@ -616,6 +616,14 @@ write_one_signatured_type (void **slot, void *d)
>> struct signatured_type *entry = (struct signatured_type *) *slot;
>> partial_symtab *psymtab = entry->per_cu.v.psymtab;
>>
>> + if (psymtab == nullptr)
>> + {
>> + /* We can end up here when processing a skeleton CU referring to a
>> + .dwo file that hasn't been found. There's not much we can do in
>> + such a case, so skip this CU. */
>> + return 1;
>> + }
>> +
>> write_psymbols (info->symtab, info->psyms_seen,
>> psymtab->global_psymbols, info->cu_index,
>> 0);
>>
> LGTM, some questions:
>
> 1. Do we need to emit a warning here? Probably not because another one
> should have been emitted earlier, when parsing symbols. But I thought
> I'd ask just in case.
>
Yeah, I think the existing warning is sufficient.
> 2. Would it be somewhat easy to write a test for this? Have a type unit
> with a dwo, delete the dwo, try to generate an index.
>
I've added a test-case to fission-reread.exp.
> 3. Is the same situation correctly handled for standard compile units?
I've tried the following experiment: I've done a gdb testsuite run with
target board fission-dwp, with a hack added to cc-with-tweaks.sh to
remove the .dwp file. Apart from a lot of FAILs, all I ran into was
PR27313 "Segfault in insert_catch_syscall" (
https://sourceware.org/bugzilla/show_bug.cgi?id=27313 ).
Committed with test-case added.
Thanks,
- Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-02-02 8:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-01 14:43 [PATCH][gdb/symtab] Fix assert in write_one_signatured_type Tom de Vries
2021-02-01 16:16 ` Simon Marchi
2021-02-02 8:34 ` Tom de Vries
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).