From 5bb7194b0a21ac7633f539634f6f3eb7ea2a22e1 Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Mon, 25 Mar 2019 14:46:31 +0100 Subject: [PATCH] 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 --- src/abg-dwarf-reader.cc | 1 + tests/data/Makefile.am | 2 ++ .../PR24378-fn-is-not-scope.abi | 18 ++++++++++++++++++ .../test-read-dwarf/PR24378-fn-is-not-scope.o | Bin 0 -> 3744 bytes tests/test-read-dwarf.cc | 6 ++++++ 5 files changed, 27 insertions(+) create mode 100644 tests/data/test-read-dwarf/PR24378-fn-is-not-scope.abi create mode 100644 tests/data/test-read-dwarf/PR24378-fn-is-not-scope.o 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 0000000000000000000000000000000000000000..02e8bb096ae0d2d88085100a4415dbdb86dcf8a6 GIT binary patch literal 3744 zcmbVO&1+m$6hC*~B$;HA=_D~VQWq(-m{NUdZ3K;yj)r^`O9_QS5p{esok@nyN0@m@ zlS=UmKLQF>5La$QH?DNyLU1Q8`Ukj`Zu|q>Rb15byYHOIdv~57J@D?m=XZYR*dPsmS5f3VFt@+G)W$LqvnH5hWQpJdW`#rEQZW} zaeO3qR}4>zT{}BfR$eX?Kgz6346EJT-n&Vcp=oPR< z-vVPr9c%s!?G^jZGC0Y7G{K*FbeA8V{MJFazT2*bjSiNc=xKf;5^su_Xy6!Rhbuv| zSqZ8)%ON$^I1rUzyRz5|gX;OkWc1a|wY|-?dZV$rN(G-%F5E*Jo}vyC-Qp-tuUx?A9kaDTSsASKP3M~ z5C-H|dOaT2xXf};sdQ_5M!S{(>fNBFNNu|;Y80^9sV2BPyOlPx zIbkeC&<)yKz#<>6k^E|>)vECp_uITcKF{hIEXz%I*&kIu!H(EV{E;W5B%1r0bzdnN zdkFq^8!O0t^lirg8M^*YF^-M(sQ%cV$nT2g|H3i2+>2~?F}VC8e)uxt;&PYR=*|iJ zx5gu{cg5j2t3&+gM>HFmX_I?5CQM%m_=@nfbGfgwAua#?iO56qAU{r4H-EsG8xx-Q z1#}Nq^#=!n6FV*c1Id5RvWSp>lppoix_XQuRsW#nF=SSNlGTnH^;ZOkR9gOd{+mJK z`SYx+zvjQgSlaxrOMcx)hy`)EpQT{neJlQ_p~S@X|AcL6^u2{vZh-XKUK};hRXyKP%_QMk4Cb zyd8KzMcOR=^>DzzfY)EWq}5BE3HWIh0#DmHz;V(IiWlAO1`M7(83tgEgD-YaJd(r3 zF?se2aX?l*yYgwcySpNeXK#0De7-F^a*Xw<*m~;!@&e;{-vg4ovizURQMtUezhBzQ8t>?{1rIPfDYu#@+xTy4@gTF2Mm(siST)yr=@O7@>&7)xf9zS37o(5dU;OW@Kbq~6E F{{>pP^i2Q& literal 0 HcmV?d00001 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} }; -- 2.43.5