Bug 29336 - [gdb, debug-types, debug-names] Bad CU index complaint not triggered
Summary: [gdb, debug-types, debug-names] Bad CU index complaint not triggered
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: symtab (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: 13.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-07-08 09:01 UTC by Tom de Vries
Modified: 2022-07-21 11:17 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
tentative patch (3.43 KB, patch)
2022-07-14 10:36 UTC, Tom de Vries
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tom de Vries 2022-07-08 09:01:13 UTC
While working on PR29334, I noticed this code right above the DW_IDX_type_unit handling code:
...
        case DW_IDX_compile_unit:
          /* Don't crash on bad data.  */
          if (ull >= per_bfd->all_comp_units.size ())
            {
              complaint (_(".debug_names entry has bad CU index %s"
                           " [in module %s]"),
                         pulongest (ull),
                         objfile_name (objfile));
              continue;
            }
          per_cu = per_bfd->get_cu (ull);
          break;
...

So, if I have 5 CUs and 5 TUs, and a ull CU index of 7, we should complain.

But we don't because we compare with "per_bfd->all_comp_units.size ()" instead of with "per_bfd->all_comp_units.size () - per_bfd->tu_stats.nr_tus".
Comment 1 Tom de Vries 2022-07-08 09:10:13 UTC
Hmm, there are similar complaints for gdb-index, perhaps the same problem in dw2_symtab_iter_next?
Comment 2 Tom de Vries 2022-07-14 10:36:24 UTC
Created attachment 14210 [details]
tentative patch
Comment 3 Tom de Vries 2022-07-14 13:35:28 UTC
(In reply to Tom de Vries from comment #1)
> Hmm, there are similar complaints for gdb-index, perhaps the same problem in
> dw2_symtab_iter_next?

Filed as PR29367.
Comment 4 Tom de Vries 2022-07-14 14:44:48 UTC
Submitted patch: https://sourceware.org/pipermail/gdb-patches/2022-July/190750.html