public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: "dodji at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: libabigail@sourceware.org
Subject: [Bug default/26135] Wrong linkage name causes anonymous classes miscomparison
Date: Wed, 24 Jun 2020 17:22:20 +0000	[thread overview]
Message-ID: <bug-26135-9487-olq1KIVCmk@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-26135-9487@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=26135

--- Comment #1 from dodji at redhat dot com ---
I can reproduce the issue.  Thank you for raising it.

Based on my current understanding of the problem, I have put together the patch
that you can get from commit
https://sourceware.org/git/?p=libabigail.git;a=commit;h=7da86264ff2c0aff7ecf1c62dee9c0d64ed11798,
from the branch dodji/PR26135.

The branch can be browed at
https://sourceware.org/git/?p=libabigail.git;a=shortlog;h=refs/heads/dodji/PR26135.

Maybe you can test it in your environment and see if it addresses the problem
you were looking at?

For the curious reader, here is an explanation of the issue.

When comparing decls, the overload of the 'equals' function for
instances of decl_base compares their linkage names.  If they are
different, then the decls are generally considered different.

Class declarations (and definitions) also use the 'equals' function
referred to above.  So when two classes have different linkage names,
they are always considered different.

Now let's consider the case of an anonymous class.  It doesn't have
any user-provided name, by definition.  Libabigail does, however,
assigns it an internal name for various (internal) purposes.  That
internal name is generally ignored for the purpose of (anonymous) type
comparison.  So by design, two anonymous classes can have different
internal anonymous names and yet still happen to be equal.

The root issue in this problem report is that by default, the linkage
name of a class is set to its name.  And when that class is anonymous,
its internal name is used as its linkage name.  Oops.  That leads to
anonymous classes being wrongly considered different.

This patch fixes the issue by providing additional constructors for a
class type to avoid using the internal anonymous name as its linkage
name.

Note that the same issue is present for unions so the patch does the
a similar thing for union types.

Enums are properly handled so we don't need to do anything in that
regard.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2020-06-24 17:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-18 16:48 [Bug default/26135] New: Possible issue with type equality gprocida+abigail at google dot com
2020-06-24 16:18 ` [Bug default/26135] " dodji at redhat dot com
2020-06-24 17:17 ` [Bug default/26135] Wrong linkage name causes anonymous classes miscomparison dodji at redhat dot com
2020-06-24 17:22 ` dodji at redhat dot com [this message]
2020-06-24 17:22 ` dodji at redhat dot com
2020-06-25 14:56 ` gprocida+abigail at google dot com
2020-07-06 17:14 ` dodji at redhat dot com
2020-07-16 11:41 ` gprocida+abigail at google dot com
2020-07-16 18:32 ` gprocida+abigail at google dot com
2020-09-17 14:17 ` dodji at redhat 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-26135-9487-olq1KIVCmk@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=libabigail@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: link
Be 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).