Bug 19092 - abidw aborts on types that violate the ODR

It appears that two different types from two different translation
units might have the same name in a DSO, like in the example of this
bug.  This violates the One Definition Rule, which we rely on to go
fast, and more importantly, it introduces type canonicalization errors.

This patch recognizes more of these ODR violation cases by looking at
the size of the types.  That is, if two types (from the same DSO) with
the same name have different sizes, then they are different.

	* src/abg-ir.cc (type_base::get_canonical_type_for): Look at the
	size of types with the same name which could be considered
	ODR-equal, to spot possible violations that would induce a type
	canonicalization error.
	* tests/data/test-read-dwarf/test21-pr19092.so: New test input
	binary.
	* tests/data/test-read-dwarf/test21-pr19092.so.abi: New reference
	abixml for the binary above.
	* tests/data/Makefile.am: Add the new test input above to source
	distribution.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
	* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/test-read-dwarf.cc (int_out_specs): Add the two test input
	above.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
Dodji Seketeli 2015-10-15 16:06:35 +02:00
parent 95de84ba2d
commit 09de4435ce
8 changed files with 36645 additions and 26799 deletions

View File

@ -6234,7 +6234,11 @@ type_base::get_canonical_type_for(type_base_sptr t)
{
if (const corpus* it_corpus = (*it)->get_corpus())
{
if (it_corpus == t_corpus)
if (it_corpus == t_corpus
// Let's add one more size constraint to rule
// out programs that break the One Definition
// Rule too easily.
&& v[0]->get_size_in_bits() == t->get_size_in_bits())
{
// Both types come from the same ABI corpus and
// have the same name; the One Definition Rule

View File

@ -300,6 +300,8 @@ test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so \
test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi \
test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so \
test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi \
test-read-dwarf/test21-pr19092.so \
test-read-dwarf/test21-pr19092.so.abi \
\
test-diff-filter/test0-v0.cc \
test-diff-filter/test0-v1.cc \

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -15057,8 +15057,10 @@
<parameter type-id='type-id-75'/>
<return type-id='type-id-41'/>
</function-decl>
<qualified-type-def type-id='type-id-503' const='yes' id='type-id-505'/>
<pointer-type-def type-id='type-id-505' size-in-bits='64' id='type-id-506'/>
<function-decl name='mbsinit' filepath='/usr/include/wchar.h' line='361' column='1' visibility='default' binding='global' size-in-bits='64'>
<parameter type-id='type-id-77'/>
<parameter type-id='type-id-506'/>
<return type-id='type-id-5'/>
</function-decl>
<function-decl name='mbsrtowcs' filepath='/usr/include/wchar.h' line='408' column='1' visibility='default' binding='global' size-in-bits='64'>

View File

@ -159,6 +159,11 @@ InOutSpec in_out_specs[] =
"data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi",
"output/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi",
},
{
"data/test-read-dwarf/test21-pr19092.so",
"data/test-read-dwarf/test21-pr19092.so.abi",
"output/test-read-dwarf/",
},
// This should be the last entry.
{NULL, NULL, NULL}
};