From: Dodji Seketeli Date: Mon, 25 Mar 2019 13:46:31 +0000 (+0100) Subject: Bug 24378 - DW_TAG_subroutine_type as a DIE scope causes infinite loop X-Git-Tag: libabigail-1.6~3 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=5bb7194b0a21ac7633f539634f6f3eb7ea2a22e1;p=libabigail.git Bug 24378 - DW_TAG_subroutine_type as a DIE scope causes infinite loop GCC 4.3.2 wrongly emits some type definition DIEs in the scope of a DW_TAG_subroutine_type. Whenever the DWARF reader tries to get the scope of a DIE during the computation of the pretty name of a type DIE which scope is (wrongly) emitted as being a DW_TAG_subroutine_type things end-up in an infinite loop. This patch makes get_scope_die to look through the DW_TAG_subroutine_type to return the proper scope instead, just like what we already do for DW_TAG_subprogram and DW_TAG_array_type. * src/abg-dwarf-reader.cc (get_scope_die): Look through DW_TAG_subroutine_type to get the scope of a given DIE. * tests/data/Makefile.am: Add the two new files below to source distribution. * tests/data/test-read-dwarf/PR24378-fn-is-not-scope.abi: New reference test output. * tests/data/test-read-dwarf/PR24378-fn-is-not-scope.o: New binary test input. * tests/test-read-dwarf.cc (in_out_specs): Add the new test input to the test harness. Signed-off-by: Dodji Seketeli --- diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index a4a2e30e..8f3052ff 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -12363,6 +12363,7 @@ get_scope_die(const read_context& ctxt, return false; if (dwarf_tag(&scope_die) == DW_TAG_subprogram + || dwarf_tag(&scope_die) == DW_TAG_subroutine_type || dwarf_tag(&scope_die) == DW_TAG_array_type) return get_scope_die(ctxt, &scope_die, where_offset, scope_die); return true; diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index 27058563..0debab90 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -397,6 +397,8 @@ test-read-dwarf/PR22015-libboost_iostreams.so \ test-read-dwarf/PR22015-libboost_iostreams.so.abi \ test-read-dwarf/PR22122-libftdc.so \ test-read-dwarf/PR22122-libftdc.so.abi \ +test-read-dwarf/PR24378-fn-is-not-scope.abi \ +test-read-dwarf/PR24378-fn-is-not-scope.o \ \ test-annotate/test0.abi \ test-annotate/test1.abi \ diff --git a/tests/data/test-read-dwarf/PR24378-fn-is-not-scope.abi b/tests/data/test-read-dwarf/PR24378-fn-is-not-scope.abi new file mode 100644 index 00000000..5ac179dd --- /dev/null +++ b/tests/data/test-read-dwarf/PR24378-fn-is-not-scope.abi @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/tests/data/test-read-dwarf/PR24378-fn-is-not-scope.o b/tests/data/test-read-dwarf/PR24378-fn-is-not-scope.o new file mode 100644 index 00000000..02e8bb09 Binary files /dev/null and b/tests/data/test-read-dwarf/PR24378-fn-is-not-scope.o differ diff --git a/tests/test-read-dwarf.cc b/tests/test-read-dwarf.cc index cd22bcc9..e743e5b6 100644 --- a/tests/test-read-dwarf.cc +++ b/tests/test-read-dwarf.cc @@ -228,6 +228,12 @@ InOutSpec in_out_specs[] = "data/test-read-dwarf/PR22122-libftdc.so.abi", "output/test-read-dwarf/PR22122-libftdc.so.abi", }, + { + "data/test-read-dwarf/PR24378-fn-is-not-scope.o", + "", + "data/test-read-dwarf/PR24378-fn-is-not-scope.abi", + "output/test-read-dwarf/PR24378-fn-is-not-scope.abi", + }, // This should be the last entry. {NULL, NULL, NULL, NULL} };