public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: Dodji Seketeli <dodji@seketeli.org>
To: "quic_ashudas at quicinc dot com" <sourceware-bugzilla@sourceware.org>
Cc: libabigail@sourceware.org, jwakely@redhat.com
Subject: Re: [Bug default/31513] abidiff differences due to change in compiler version
Date: Thu, 21 Mar 2024 11:19:23 +0100	[thread overview]
Message-ID: <87edc328gk.fsf@seketeli.org> (raw)
In-Reply-To: <bug-31513-9487-HDIe7yyIas@http.sourceware.org/bugzilla/> (quic ashudas at quicinc dot com's message of "Wed, 20 Mar 2024 10:54:56 +0000")

Hello,

> Attached the required libraries.

Thanks!  These have been really useful.

So here is my analysis, looking at the debug info.

I think it all boils down to a change in the implementation details of
the vector type of the standard library.  Namely, the type:
    _Vector_base<char, std::allocator<char> >::_Vector_impl.

Let's look at a dump of the DWARF debuginfo for that type in the binary
resulting from the libstdc++ implementation for gcc7.xx:


     [  2c03]        structure_type       abbrev: 17
                     name                 (strp) "_Vector_impl"
                     byte_size            (data1) 24
                     decl_file            (data1) stl_vector.h (3)
                     decl_line            (data1) 81
                     sibling              (ref4) [  2cc5]
     [  2c0f]          inheritance          abbrev: 59
                       type                 (ref4) [  2540]
                       data_member_location (data1) 0
     [  2c15]          member               abbrev: 7
                       name                 (strp) "_M_start"
                       decl_file            (data1) stl_vector.h (3)
                       decl_line            (data1) 84
                       type                 (ref4) [  2cc5]
                       data_member_location (data1) 0
     [  2c21]          member               abbrev: 7
                       name                 (strp) "_M_finish"
                       decl_file            (data1) stl_vector.h (3)
                       decl_line            (data1) 85
                       type                 (ref4) [  2cc5]
                       data_member_location (data1) 8
     [  2c2d]          member               abbrev: 7
                       name                 (strp) "_M_end_of_storage"
                       decl_file            (data1) stl_vector.h (3)
                       decl_line            (data1) 86
                       type                 (ref4) [  2cc5]
                       data_member_location (data1) 16
     [...]


So we see that the _Vector_impl type inherits a type identified by the
DIE (debug information entry) at offset 0x2540 (which happens to be the
type allocator<char>) and has three data members: _M_start, _M_finish,
and _M_end_of_storage.


Now, let's look at the similar dump of the DWARF debuginfo for that type
in the binary resulting from the libstdc++ implementation for gcc11.xx:


     [  36b3]        structure_type       abbrev: 23
                     name                 (strp) "_Vector_impl"
                     byte_size            (data1) 24
                     decl_file            (data1) stl_vector.h (3)
                     decl_line            (data1) 128
                     decl_column          (data1) 14
                     sibling              (ref4) [  377e]
     [  36c0]          inheritance          abbrev: 50
                       type                 (ref4) [   bb5]
                       data_member_location (implicit_const) 0
     [  36c5]          inheritance          abbrev: 50
                       type                 (ref4) [  35f9]
                       data_member_location (implicit_const) 0
     [  36ca]          subprogram           abbrev: 24
                       external             (flag_present) yes
                       name                 (strp) "_Vector_impl"
                       decl_file            (data1) stl_vector.h (3)
                       decl_line            (data1) 131
                       decl_column          (data1) 2
                       linkage_name         (strp) "_ZNSt12_Vector_baseIcSaIcEE12_Vector_implC4Ev"
                       declaration          (flag_present) yes
                       object_pointer       (ref4) [  36de]
                       sibling              (ref4) [  36e4]
     [  36de]            formal_parameter     abbrev: 2
                         type                 (ref4) [  6bce]
                         artificial           (flag_present) yes
     [  36e4]          subprogram           abbrev: 24

     [...]

Here, we see that the _Vector_impl inherits *TWO* types.  One is
identified by the DIE at offset 0xbb5 (which is the type
allocator<char>) and the other is the type identified by the DIE at
offset 0x35f9 which the (newly introduced) type:

    "_Vector_base<char, std::allocator<char> >::_Vector_impl_data"

And we see that this new implementation of _Vector_impl doesn't have any
of the data members _M_start, _M_finish,  _M_end_of_storage.  Now let's
look at the DIE for the type:

    "_Vector_base<char, std::allocator<char> >::_Vector_impl_data"


 [  35f9]        structure_type       abbrev: 23
                 name                 (strp) "_Vector_impl_data"
                 byte_size            (data1) 24
                 decl_file            (data1) stl_vector.h (3)
                 decl_line            (data1) 91
                 decl_column          (data1) 14
                 sibling              (ref4) [  36a2]
 [  3606]          member               abbrev: 6
                   name                 (strp) "_M_start"
                   decl_file            (data1) stl_vector.h (3)
                   decl_line            (data1) 93
                   decl_column          (data1) 10
                   type                 (ref4) [  36a7]
                   data_member_location (data1) 0
 [  3613]          member               abbrev: 6
                   name                 (strp) "_M_finish"
                   decl_file            (data1) stl_vector.h (3)
                   decl_line            (data1) 94
                   decl_column          (data1) 10
                   type                 (ref4) [  36a7]
                   data_member_location (data1) 8
 [  3620]          member               abbrev: 6
                   name                 (strp) "_M_end_of_storage"
                   decl_file            (data1) stl_vector.h (3)
                   decl_line            (data1) 95
                   decl_column          (data1) 10
                   type                 (ref4) [  36a7]
                   data_member_location (data1) 16
 [...]
 

We see that this new type has the three data members _M_start,
_M_finish,  _M_end_of_storage that are missing from _Vector_impl.

In other words, the data members of the class _Vector_impl in gcc7 were moved to
the class _Vector_impl_data in gcc11 and _Vector_impl now inherits
_V_Vector_impl_data.

Note that the layout of the _Vector_impl hasn't changed.  Its size
hasn't changed either.  This is coherent with what abidiff says, when it
says that the size hasn't changed (and when it doesn't report any offset change):

                  type of 'std::_Vector_base<char, std::allocator<char> >::_Vector_impl _M_impl' changed:
                    type size hasn't changed
                    1 base class insertion:
                      struct std::_Vector_base<char, std::allocator<char> >::_Vector_impl_data at stl_vector.h:91:1
                    3 data member deletions:
                      'std::_Vector_base<char, std::allocator<char> >::pointer _M_start', at offset 0 (in bits) at stl_vector.h:84:1
                      'std::_Vector_base<char, std::allocator<char> >::pointer _M_finish', at offset 64 (in bits) at stl_vector.h:85:1
                      'std::_Vector_base<char, std::allocator<char> >::pointer _M_end_of_storage', at offset 128 (in bits) at stl_vector.h:86:1


In other words, this is not an incompatible ABI change.  I'd argue that
it's not even an ABI change.

Now, I am thinking that *maybe* we should make libabigail detect that
the data members _M_start, _M_finish and _M_end_of_storage were moved to
the new base class _Vector_impl_data with no observable change to the
layout of the _Vector_impl class.  This would have made the analysis
much simpler for the user.  What do you think?  If you agree, then I
think we should add a new enhancement request for that feature.

> Ques 1: Is this behavior expected as we have not made any change in the source
> files of the library the highlighted changes are in compiler source files.

I guess I would answer "it depends".  Sorry.

This is a real change that happened in the implementation details of the
libstdc++ standard library.  If, for a reason, you are interested in
reviewing this kind of changes you might be interested in *seeing* them
in the first place.

If, on the other hand, you are not interested in the changes about types
(that are implementation details) of the libstdc++ standard library,
then yes, these changes should be suppressed from the output of
abidiff.  You should be able to control this behavior, I think.


> Ques 2: If yes, can you share a suppression file to ignore all the
> changes which are not from the elf source file.

So, here is an example of suppression file that you could use, if you
want to suppress all the changes to the types of the "std" namespace:

---------->8<---------------------
[suppress_type]
  # Suppress changes in types of the std:: namespace
  name_regexp = ^std::.*
--------->8<----------------------

For the record, here is what I am getting when using a suppression file
with that content:


        $ cat default.suppr
        [suppress_type]
          # Suppress changes in types of the std:: namespace
          name_regexp = ^std::.*

        $ abidiff --suppr default.suppr bin/libloremipsum_gcc7.so bin/libloremipsum_gcc11.so
        Functions changes summary: 16 Removed, 0 Changed (20 filtered out), 21 Added functions
        Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
        Function symbols changes summary: 2 Removed, 2 Added function symbols not referenced by debug info
        Variable symbols changes summary: 0 Removed, 0 Added variable symbol not referenced by debug info

        [...]
        $

Note how all the *type changes* got filtered out, as shown in the summary.

I hope this helps.

-- 
		Dodji

  reply	other threads:[~2024-03-21 10:19 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-20  5:57 [Bug default/31513] New: " quic_ashudas at quicinc dot com
2024-03-20 10:22 ` [Bug default/31513] " dodji at redhat dot com
2024-03-20 10:53 ` quic_ashudas at quicinc dot com
2024-03-20 10:54 ` quic_ashudas at quicinc dot com
2024-03-20 10:54 ` quic_ashudas at quicinc dot com
2024-03-21 10:19   ` Dodji Seketeli [this message]
2024-03-20 19:14 ` woodard at redhat dot com
2024-03-21  6:51 ` quic_ashudas at quicinc dot com
2024-03-21 10:19 ` dodji at seketeli dot org
2024-03-22  6:36 ` quic_ashudas at quicinc dot com
2024-03-22  6:36 ` quic_ashudas at quicinc dot com
2024-03-22  9:20 ` dodji at redhat dot com
2024-03-22  9:20 ` dodji at redhat dot com
2024-03-28 16:41 ` [Bug default/31513] abidiff wrongly considers data members moved to base class as harmful dodji at seketeli dot org
2024-03-29 17:40 ` dodji at seketeli dot org
2024-04-01 14:28 ` quic_ashudas at quicinc dot com
2024-04-02  9:54 ` dodji at seketeli dot org
2024-04-02 13:16 ` quic_jiafan at quicinc dot com
2024-04-03  9:58   ` Dodji Seketeli
2024-04-03  9:58 ` dodji at seketeli dot org
2024-04-03 10:22 ` quic_jiafan at quicinc dot com
2024-04-03 16:26 ` dodji at seketeli dot org

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=87edc328gk.fsf@seketeli.org \
    --to=dodji@seketeli.org \
    --cc=jwakely@redhat.com \
    --cc=libabigail@sourceware.org \
    --cc=sourceware-bugzilla@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).