public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
* [Bug default/28025] New: exceptions are not checked for ABI compatibility.
@ 2021-06-29 15:28 woodard at redhat dot com
  2021-06-30 23:09 ` [Bug default/28025] " woodard at redhat dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: woodard at redhat dot com @ 2021-06-29 15:28 UTC (permalink / raw)
  To: libabigail

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

            Bug ID: 28025
           Summary: exceptions are not checked for ABI compatibility.
           Product: libabigail
           Version: unspecified
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: default
          Assignee: dodji at redhat dot com
          Reporter: woodard at redhat dot com
                CC: libabigail at sourceware dot org
  Target Milestone: ---

Libabigail doesn't inspect types which are thrown for compatibility this can
lead to ABI errors. The reason for this appears to be that it believes that the
types are private and therefore not part of the exported ABI. 

Here is an example that shows that they are.

$ for i in rtti-exception.[hC] use-rtti-excep.C;do echo --- $i;cat $i;done
--- rtti-exception.C
#include <iostream>
#include "rtti-exception.h"

extern int do_something( int num){
  std::cout << "did something\n";
  throw ex(num);
}
--- rtti-exception.h
#ifdef VER_1
class ex {
public:
  int num;
  ex( int n):num(n){}
};
#endif

#ifdef VER_2
class ex {
  float num;
public:
  ex( int n):num(n){}
};
#endif

int do_something( int num);
--- use-rtti-excep.C
#define VER_1

#include <iostream>

#include "rtti-exception.h"

int main( int argc, char **argv){
  try{
    do_something( 3);
  }
  catch( ex &excep){
    std::cout << "caught " << excep.num << std::endl;
  }
  return 0;
}

$ abidiff librttiexcep_v1.so librttiexcep_v2.so ;echo $?
0
$ abidiff rtti-v1.o rtti-v2.o ;echo $?
0
$ export SWAP_LIB_FILENAME=libswapfile
$ LD_LIBRARY_PATH=. ./use-rtti-excep
did something
caught 3
$ LD_AUDIT=./swap-libs-audit.so LD_LIBRARY_PATH=. ./use-rtti-excep 
did something
caught 1077936128

It is believed that types that there is enough information in the LSDA of the
object doing the throwing to be able to identify the type being thrown. It can
then be added to the list of types which must be compared when comparing
libraries.

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug default/28025] exceptions are not checked for ABI compatibility.
  2021-06-29 15:28 [Bug default/28025] New: exceptions are not checked for ABI compatibility woodard at redhat dot com
@ 2021-06-30 23:09 ` woodard at redhat dot com
  2021-07-01 16:35 ` woodard at redhat dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: woodard at redhat dot com @ 2021-06-30 23:09 UTC (permalink / raw)
  To: libabigail

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

--- Comment #1 from Ben Woodard <woodard at redhat dot com> ---
This is entirely not documented well and I've been searching for this
everywhere.

The name of the class that is being thrown can be found in the LSDA.
So basically the way that you can find it is:
$ eu-readelf -l librttiexcep_v1.so | grep GNU_EH_FRAME
  GNU_EH_FRAME   0x002014 0x0000000000002014 0x0000000000002014 0x000024
0x000024 R   0x4
so in that case the offset is 0x2014. 
Then if you actually go to that offset in the ELF file you will come to a
structure which is a LSDA as defined by the gnu compiler. As far as I have been
able to tell it is not documented anywhere but it is in gcc/libgcc/unwind-c.c
typedef struct
{
  _Unwind_Ptr Start;
  _Unwind_Ptr LPStart;
  _Unwind_Ptr ttype_base;
  const unsigned char *TType;
  const unsigned char *action_table;
  unsigned char ttype_encoding;
  unsigned char call_site_encoding;
} lsda_header_info;

The TTtype is a reverse index from that offset. So the strings which have the
names are before the offset for each LSDA header.
Ian Taylor kind of opaquely explained that at the end of:
https://www.airs.com/blog/archives/464

We need to add the types found in the LSDA to the types we compare when we do
an abidiff libfoo.so libfoo'.so

When you do abicompat app libfoo.so libfoo'.so you must add the types found in
that TType table to the types picked up from the undefined symbols to the list
of types that you compare from libfoo.so to libfoo'.so

Finding the TType table for the catches you can simply look at:
$ eu-readelf --debug-dump=frame use-rtti-excep | grep -A1 "TType table"
 TType table:
 [   1] 0x402038

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug default/28025] exceptions are not checked for ABI compatibility.
  2021-06-29 15:28 [Bug default/28025] New: exceptions are not checked for ABI compatibility woodard at redhat dot com
  2021-06-30 23:09 ` [Bug default/28025] " woodard at redhat dot com
@ 2021-07-01 16:35 ` woodard at redhat dot com
  2021-07-02  0:35 ` woodard at redhat dot com
  2021-09-07 18:20 ` woodard at redhat dot com
  3 siblings, 0 replies; 5+ messages in thread
From: woodard at redhat dot com @ 2021-07-01 16:35 UTC (permalink / raw)
  To: libabigail

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

--- Comment #2 from Ben Woodard <woodard at redhat dot com> ---
See also: https://sourceware.org/bugzilla/show_bug.cgi?id=28043

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug default/28025] exceptions are not checked for ABI compatibility.
  2021-06-29 15:28 [Bug default/28025] New: exceptions are not checked for ABI compatibility woodard at redhat dot com
  2021-06-30 23:09 ` [Bug default/28025] " woodard at redhat dot com
  2021-07-01 16:35 ` woodard at redhat dot com
@ 2021-07-02  0:35 ` woodard at redhat dot com
  2021-09-07 18:20 ` woodard at redhat dot com
  3 siblings, 0 replies; 5+ messages in thread
From: woodard at redhat dot com @ 2021-07-02  0:35 UTC (permalink / raw)
  To: libabigail

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

--- Comment #3 from Ben Woodard <woodard at redhat dot com> ---
I put a full example in https://github.com/buildsi/build-abi-tests.git

From the top level you can just do 'make test' it will build everything and run
the tests. You can then inspect the objects which are in the tests subdir or
run the libabigail tests out of the libabigail subdir.

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug default/28025] exceptions are not checked for ABI compatibility.
  2021-06-29 15:28 [Bug default/28025] New: exceptions are not checked for ABI compatibility woodard at redhat dot com
                   ` (2 preceding siblings ...)
  2021-07-02  0:35 ` woodard at redhat dot com
@ 2021-09-07 18:20 ` woodard at redhat dot com
  3 siblings, 0 replies; 5+ messages in thread
From: woodard at redhat dot com @ 2021-09-07 18:20 UTC (permalink / raw)
  To: libabigail

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

Ben Woodard <woodard at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |27019


Referenced Bugs:

https://sourceware.org/bugzilla/show_bug.cgi?id=27019
[Bug 27019] BUILD metabug
-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-09-07 18:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-29 15:28 [Bug default/28025] New: exceptions are not checked for ABI compatibility woodard at redhat dot com
2021-06-30 23:09 ` [Bug default/28025] " woodard at redhat dot com
2021-07-01 16:35 ` woodard at redhat dot com
2021-07-02  0:35 ` woodard at redhat dot com
2021-09-07 18:20 ` woodard at redhat dot com

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).