Bug 260818 - ctfconvert errors when processing iwlwifi object files
Summary: ctfconvert errors when processing iwlwifi object files
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Mark Johnston
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-12-30 15:06 UTC by Mark Johnston
Modified: 2022-01-07 14:06 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Johnston freebsd_committer freebsd_triage 2021-12-30 15:06:07 UTC
$ cd sys/modules/iwlwifi
$ make -s WITH_CTF= DEBUG_FLAGS=-g
ctfconvert: failed to resolve the following types:                             
struct 65360 <ff50>: failed to size member "desc" of type  (65453 <ffad>)      
ERROR: ctfconvert: failed to resolve types                                     
ctfconvert: failed to resolve the following types:                             
struct 66979 <105a3>: failed to size member "desc" of type  (67072 <10600>)                                                                                   
ERROR: ctfconvert: failed to resolve types                                     
ctfconvert: failed to resolve the following types:                                                                                                            
struct 66556 <103fc>: failed to size member "desc" of type  (66649 <10459>)                                                                                   
ERROR: ctfconvert: failed to resolve types                                                                                                                    
ctfconvert: failed to resolve the following types:
...

Looks like all the warnings are about the "desc" field of struct iwl_p2p_noa_attr, which is:

  struct ieee80211_p2p_noa_desc desc[IWL_P2P_NOA_DESC_COUNT];

and we have

  struct ieee80211_p2p_noa_desc {
	/* TODO FIXME */
  };

Adding a dummy field to the latter "fixes" the problem.

Looking at ctfconvert, empty structs and unions are permitted and handled, as are flexible array members.  The problem is that here we have an array of empty structs.  I think die_sou_resolve() needs some extra logic to handle this case.
Comment 1 Mark Johnston freebsd_committer freebsd_triage 2021-12-30 15:14:56 UTC
https://reviews.freebsd.org/D33700
Comment 2 Bjoern A. Zeeb freebsd_committer freebsd_triage 2021-12-30 17:18:55 UTC
Is there any way we could use dwarf debug information to make the output of ctfconvert more clear as to where the error comes from?  I know that is a different problem than this PR, just wondering how you gt from a to b?
Comment 3 Mark Johnston freebsd_committer freebsd_triage 2021-12-30 17:43:29 UTC
(In reply to Bjoern A. Zeeb from comment #2)
The string "failed to size member "desc"" made it clear that there is a struct or union member "desc" that is causing problems.  Looking at iwlwifi sources, there are only a couple of members with that name, and a bit of reading suggested that the array of structs of size zero might be the problem, since that represents an unusual case.

The warning string doesn't include the type name (it should be " of type foo"), but here nothing gets printed, I think because the member is an array type and DWARF doesn't supply a DW_AT_name attribute for such types.  We could perhaps make it smarter and synthesize a name, "array of <content type>", but that string might not be available yet depending on the ordering of DWARF DIEs, and it's possible to hit this error before the type names are fully resolved, I think...
Comment 4 commit-hook freebsd_committer freebsd_triage 2021-12-31 18:10:16 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=963f5dc7a30624e95d72fb7f87b8892651164e46

commit 963f5dc7a30624e95d72fb7f87b8892651164e46
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2021-12-31 17:55:01 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2021-12-31 17:55:01 +0000

    ctfconvert: Handle arrays of empty structs

    Members with such a type will legitimately have a size of zero, so don't
    emit a warning.

    PR:             260818
    Reviewed by:    bz
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D33700

 cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
Comment 5 commit-hook freebsd_committer freebsd_triage 2022-01-07 14:03:45 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=ed0748f1a8fa064bea81c0c0068e78aa69ee5b0a

commit ed0748f1a8fa064bea81c0c0068e78aa69ee5b0a
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2021-12-31 17:55:01 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2022-01-07 14:03:02 +0000

    ctfconvert: Handle arrays of empty structs

    Members with such a type will legitimately have a size of zero, so don't
    emit a warning.

    PR:             260818
    Reviewed by:    bz
    Sponsored by:   The FreeBSD Foundation

    (cherry picked from commit 963f5dc7a30624e95d72fb7f87b8892651164e46)

 cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)