public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
* [Bug default/19734] New: Shifted exported fields in c++ classes are not detected as abi breakage
@ 2016-01-01  0:00 dank at kegel dot com
  2016-01-01  0:00 ` [Bug default/19734] Libabigail skips the 'this' pointer when comparing two member functions dodji at redhat dot com
  2020-11-11 16:07 ` maennich at android dot com
  0 siblings, 2 replies; 3+ messages in thread
From: dank at kegel dot com @ 2016-01-01  0:00 UTC (permalink / raw)
  To: libabigail

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

            Bug ID: 19734
           Summary: Shifted exported fields in c++ classes are not
                    detected as abi breakage
           Product: libabigail
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: default
          Assignee: dodji at redhat dot com
          Reporter: dank at kegel dot com
                CC: libabigail at sourceware dot org
  Target Milestone: ---

abidiff fails to detect abi breakage from added structure members.
To demonstrate, create these files, then run foo.sh:

::::::::::::::
foo_h
::::::::::::::
struct __attribute__ ((visibility ("default"))) lego {
    #ifdef VERSION2
    char buggy_symbol[10];
    #else
    char buggy_symbol[5];
    #endif
    int payload;

    lego();

    int get() { return payload; }
    int set(int x) { payload = x; }
};
::::::::::::::
foo.cpp
::::::::::::::
#include "foo.h"

lego::lego() : payload(42) {}
::::::::::::::
main.cpp
::::::::::::::
#include "foo.h"
#include <assert.h>

int main(int argc, char **argv)
{
    lego x;
    assert(x.get() == 42);
    return (x.get() == 42) ? 0 : 1;
}
::::::::::::::
foo.sh
::::::::::::::
#!/bin/sh
set -e
set -x
rm -rf v1 v2
mkdir v1 v2
cp foo_h v1/foo.h
echo "#define VERSION2 1" > v2/foo.h
cat foo_h >> v2/foo.h

# Build library version 1
g++ -g -I v1 foo.cpp -shared -fpic -o libfoo1.so -g
# Build library version 2
g++ -g -I v2 foo.cpp -shared -fpic -o libfoo2.so -g
# abidiff reports no ABI breakage between version 1 and version 2
abidiff libfoo1.so libfoo2.so
# but abidw shows the abi breakage is potentially detectable:
abidw libfoo1.so > abi1.xml
abidw libfoo2.so > abi2.xml
diff -u abi1.xml abi2.xml

# App built against version 1 runs fine against version 1
g++ -g -I v1 main.cpp ./libfoo1.so -o main1
./main1 || echo failed
# App built against version 2 crashes when run against version 1 despite
all-clear from abidiff
g++ -g -I v2 main.cpp ./libfoo1.so -o main2
./main2 || echo failed

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

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

end of thread, other threads:[~2020-11-11 16:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-01  0:00 [Bug default/19734] New: Shifted exported fields in c++ classes are not detected as abi breakage dank at kegel dot com
2016-01-01  0:00 ` [Bug default/19734] Libabigail skips the 'this' pointer when comparing two member functions dodji at redhat dot com
2020-11-11 16:07 ` maennich at android 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).