[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug default/21843] libabigail getting confused or possibly bad dwarf



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

--- Comment #2 from Ben Woodard <woodard at redhat dot com> ---
I'm becoming increasingly convinced that it is libabigail that is going off in
the weeds here and I think it has to do with template specialization that ends
up being nothing.

when you look at the DWARF from clang and track down the specialization of
pointer in line 113
 [    2a]    variable
             name                 (strp) "var"
             type                 (ref4) [    47]
             external             (flag_present) yes
             decl_file            (data1) 6
             decl_line            (data1) 3
             location             (exprloc) 
              [   0] addr .bss+0 <var>
 [    3f]    namespace
             name                 (strp) "std"
             decl_file            (data1) 1
             decl_line            (data2) 2190
 [    47]      class_type
               name                 (strp) "vector<int, std::allocator<int> >"
               byte_size            (data1) 24
               decl_file            (data1) 5
               decl_line            (data1) 216
...
 [   74c]      class_type
               name                 (strp) "allocator<int>"
               byte_size            (data1) 1
               decl_file            (data1) 4
               decl_line            (data1) 108
...
 [   793]        typedef
                 type                 (ref4) [   b04]
                 name                 (strp) "pointer"
                 decl_file            (data1) 4
                 decl_line            (data1) 113
...
 [   b04]    pointer_type
             type                 (ref4) [   b09]
 [   b09]    base_type
             name                 (strp) "int"
             encoding             (data1) signed (5)
             byte_size            (data1) 4

So when libabigail says: 
                   typedef name changed from
std::allocator_traits<std::allocator<int> >::pointer to
std::allocator<int>::pointer at allocator.h:113:1

pointer is in the std namespace and the typedef is defined inside the
specialization of the allocator<int> class so that all makes sense.

However, when we reverse the order of the abidiff command line we get a
different error message:
[ben@localhost c++test]$ abidiff --no-unreferenced-symbols --harmless
test4-clang.o  test4-gcc.o 
Functions changes summary: 0 Removed, 0 Changed, 0 Added function
Variables changes summary: 0 Removed, 1 Changed, 0 Added variable

1 Changed variable:

  [C]'std::vector<int, std::allocator<int> > var' was changed at test4.C:3:1:
    type of variable changed:
     type size hasn't changed
     1 base class change:
       'struct std::_Vector_base<int, std::allocator<int> >' at
stl_vector.h:74:1 changed:
         type size hasn't changed
         1 data member change:
          type of 'std::_Vector_base<int, std::allocator<int> >::_Vector_impl
std::_Vector_base<int, std::allocator<int> >::_M_impl' changed:
            type size hasn't changed
            3 data member changes:
             type of 'std::_Vector_base<int, std::allocator<int> >::pointer
std::_Vector_base<int, std::allocator<int> >::_Vector_impl::_M_start' changed:
               underlying type 'typedef
__gnu_cxx::__alloc_traits<std::allocator<int> >::pointer' at
alloc_traits.h:59:1 changed:
                 underlying type 'typedef std::allocator<int>::pointer' at
alloc_traits.h:392:1 changed:
                   'typedef std::allocator<int>::pointer' access changed from
'private' to 'public'
                   typedef name changed from std::allocator<int>::pointer to
std::allocator_traits<std::allocator<int> >::pointer at alloc_traits.h:392:1


             type of 'std::_Vector_base<int, std::allocator<int> >::pointer
std::_Vector_base<int, std::allocator<int> >::_Vector_impl::_M_finish' changed:
               underlying type 'typedef
__gnu_cxx::__alloc_traits<std::allocator<int> >::pointer' at
alloc_traits.h:59:1 changed:
                 underlying type 'typedef std::allocator<int>::pointer' at
alloc_traits.h:392:1 changed:
                   'typedef std::allocator<int>::pointer' access changed from
'private' to 'public'
                   typedef name changed from std::allocator<int>::pointer to
std::allocator_traits<std::allocator<int> >::pointer at alloc_traits.h:392:1


             type of 'std::_Vector_base<int, std::allocator<int> >::pointer
std::_Vector_base<int, std::allocator<int> >::_Vector_impl::_M_end_of_storage'
changed:
               underlying type 'typedef
__gnu_cxx::__alloc_traits<std::allocator<int> >::pointer' at
alloc_traits.h:59:1 changed:
                 underlying type 'typedef std::allocator<int>::pointer' at
alloc_traits.h:392:1 changed:
                   'typedef std::allocator<int>::pointer' access changed from
'private' to 'public'
                   typedef name changed from std::allocator<int>::pointer to
std::allocator_traits<std::allocator<int> >::pointer at alloc_traits.h:392:1

Note the difference with gcc first:
typedef name changed from std::allocator_traits<std::allocator<int> >::pointer
to std::allocator<int>::pointer at allocator.h:113:1

with clang first:
typedef name changed from std::allocator<int>::pointer to
std::allocator_traits<std::allocator<int> >::pointer at alloc_traits.h:392:1

It is not comparing the same "pointer" class. One is typedef'd inside of
std::allocator<int> and the other is typedef'd inside of
std::allocator_traits<std::allocator<int> >. I admit that this is really hard
to follow manually in GCC's DWARF because of the importing that GCC does but I
think that puzzling it together, this has enough of the DWARF to show that
libabigail is comparing two different "pointer" typedefs from different
template specializations.

 [   410]      structure_type
               name                 (strp)
"allocator_traits<std::allocator<int> >"
               byte_size            (data1) 1
               decl_file            (data1) 4
               decl_line            (data2) 384
               sibling              (ref4) [   50b]
 [   43a]        typedef
                 name                 (strp) "pointer"
                 decl_file            (data1) 4
                 decl_line            (data2) 392
                 type                 (ref4) [  16c6]
...
 [  12e0]    namespace
             name                 (strp) "__gnu_cxx"
             decl_file            (data1) 8
             decl_line            (data2) 2216
             sibling              (ref4) [  15be]
 [  12ec]      namespace
               name                 (strp) "__cxx11"
               decl_file            (data1) 8
               decl_line            (data2) 2218
 [  12f4]      imported_module
               decl_file            (data1) 8
               decl_line            (data2) 2218
               import               (ref4) [  12ec]
 ...
 [  1353]      structure_type
               name                 (strp) "__alloc_traits<std::allocator<int>
>"
               byte_size            (data1) 1
               decl_file            (data1) 16
               decl_line            (data1) 50
               sibling              (ref4) [  1454]
...
 [  1374]        inheritance
                 type                 (ref4) [   410]
                 data_member_location (data1) 0

...
 [  15ef]    base_type
             byte_size            (data1) 4
             encoding             (data1) signed (5)
             name                 (string) "int"
 [  16c6]    pointer_type
             byte_size            (data1) 8
             type                 (ref4) [  15ef]

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