public inbox for gdb-prs@sourceware.org help / color / mirror / Atom feed
From: "dje at google dot com" <sourceware-bugzilla@sourceware.org> To: gdb-prs@sourceware.org Subject: [Bug gdb/17450] New: resolve_dynamic_type_internal misunderstands check_typedef -> internal error Date: Wed, 01 Oct 2014 17:57:00 -0000 [thread overview] Message-ID: <bug-17450-4717@http.sourceware.org/bugzilla/> (raw) https://sourceware.org/bugzilla/show_bug.cgi?id=17450 Bug ID: 17450 Summary: resolve_dynamic_type_internal misunderstands check_typedef -> internal error Product: gdb Version: HEAD Status: NEW Severity: normal Priority: P2 Component: gdb Assignee: unassigned at sourceware dot org Reporter: dje at google dot com Clang is emitting no bounds info for the "x" in class c { char x[0]; char more_x[42]; }; This causes has_static_range for "x" to return false (lower bound is defaulted to zero, upper bound is unknown), which in turn causes is_dynamic_type to return true and we enter resolve_dynamic_type (which is just a wrapper on resolve_dynamic_type_internal). In the example at hand (I don't have an easy to provide testcase, at least not yet), the type is defined in another CU so what resolve_dynamic_type gets is an opaque type. We then hit this assert in resolve_dynamic_struct and crash: gdb_assert (TYPE_NFIELDS (type) > 0); resolve_dynamic_type_internal seems to not understand that check_typedef has (at least) two main purposes: 1) check for typedefs (duh ... :-)), 2) AND resolve opaque types. It's easy to understand this happening given how poorly named check_typedef is. static struct type * resolve_dynamic_type_internal (struct type *type, CORE_ADDR addr, int top_level) { struct type *real_type = check_typedef (type); struct type *resolved_type = type; const struct dynamic_prop *prop; CORE_ADDR value; if (!is_dynamic_type_internal (real_type, top_level)) return type; switch (TYPE_CODE (type)) { ... case TYPE_CODE_STRUCT: resolved_type = resolve_dynamic_struct (type, addr); break; } ... } Note that we've called check_typedef, BUT we're passing type to resolve_dynamic_struct not real_type. If type is an opaque type we in fact do want to pass real_type to resolve_dynamic_struct. Either that or call check_typedef again in resolve_dynamic_struct. Since this collection of functions is all just implementation detail for resolve_dynamic_type I'm ok with not sprinkling calls to check_typedef everywhere it might be needed (and in fact since the function is so badly named sprinkling it about doesn't improve readability). It would be reasonable to create a resolve_opaque_type function that handles this part of what check_typedef does, and use that instead, but I'm ok with just passing real_type to resolve_dynamic_struct here. -- You are receiving this mail because: You are on the CC list for the bug.
next reply other threads:[~2014-10-01 17:57 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-10-01 17:57 dje at google dot com [this message] 2014-11-27 0:23 ` [Bug gdb/17450] " dje at google dot com 2014-11-27 23:09 ` jan.kratochvil at redhat dot com 2014-11-27 23:49 ` dje at google dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-17450-4717@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=gdb-prs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).