Created attachment 40754 [details] package body Here is a reproducer for regression in GCC 7. The regression was found by fedora project while recompiling packages with new compiler. gcc 6, gcc 5 works fine with it. gcc version 7.0.1 20170212 (experimental) (GCC) Target: x86_64-pc-linux-gnu Configured with: /work/reznik/gcc/gcc-7-20170212/configure --enable-languages=ada,c,c++ --prefix=/work/reznik/gcc/install --disable-multilib Command line: gcc -O2 -c -g finite_automatons.adb Output: +===========================GNAT BUG DETECTED==============================+ | 7.0.1 20170212 (experimental) (x86_64-pc-linux-gnu) GCC error: | | in add_gnat_descriptive_type_attribute, at dwarf2out.c:19511 | | Error detected around finite_automatons.adb:34:8 | | Please submit a bug report; see https://gcc.gnu.org/bugs/ . | | Use a subject line meaningful to you and us to track the bug. | | Include the entire contents of this bug box in the report. | | Include the exact command that you entered. | | Also include sources listed below. | +==========================================================================+ Please include these source files with error report Note that list may not be accurate in some cases, so please double check that the problem can still be reproduced with the set of files listed. Consider also -gnatd.n switch (see debug.adb). finite_automatons.adb finite_automatons.ads raised TYPES.UNRECOVERABLE_ERROR : comperr.adb:406
Created attachment 40755 [details] package spec
Known issue, no need to open a ticket multiple times...
Thank you for CCing me, Jakub. This is just to say that I will not be able to work on this until March. If this can wait until then, I’ll be happy to investigate and try to fix the crash.
GCC 7.1 has been released.
I hit this bug using GCC 7.1.0 on the same package but different OS (DragonFly x86_64 was used). I understand there is a patch for review to fix this: https://gcc.gnu.org/ml/gcc-patches/2017-05/msg02049.html It was submitted in late May, so could somebody with approval authority take a look at Pierre-Marie's patch? It fixes an ICE and a regression on a release so in my opinion it's relatively high priority.
It looks like the release of 7.2 is upcoming. It would be really great if this ICE/Regression is addressed for that release. Is there any way to raise the visibility on this issue to avoid missing a fix for 7.2?
(In reply to John Marino from comment #6) > It looks like the release of 7.2 is upcoming. It would be really great if > this ICE/Regression is addressed for that release. Is there any way to > raise the visibility on this issue to avoid missing a fix for 7.2? I would be all for it. For the record, I sent a PING for my patch on gcc-patches@ on Monday: <https://gcc.gnu.org/ml/gcc-patches/2017-07/msg01391.html>.
Author: pmderodat Date: Sat Aug 12 09:07:12 2017 New Revision: 251066 URL: https://gcc.gnu.org/viewcvs?rev=251066&root=gcc&view=rev Log: [PR79542][Ada] Fix ICE in dwarf2out.c with nested func. inlining https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79542 reports an ICE in dwarf2out.c for an Ada testcase built with optimization. This crash happens during the late generation pass because add_gnat_descriptive_type cannot find the type DIE corresponding to some descriptive type after having tried to generate it. This is because the DIE was generated during the early generation pass, but then pruned by the type pruning machinery. So why was it pruned? We are in a situation where we have cloned types (because of inlining, IIUC) whose TYPE_NAME have non-null DECL_ABSTRACT_ORIGIN attributes. As a consequence: * In modified_type_die, the "handle C typedef types" part calls gen_type_die on the cloned type. * gen_type_die matches a typedef variant, and then calls gen_decl_die on its TYPE_NAME, which will end up calling gen_typedef_die. * gen_typedef_die checks decl_ultimate_origin for this TYPE_DECL, and finds one, so it only adds a DW_AT_abstract_origin attribute to the DW_TAG_typedef DIE, but the cloned type itself does not get its own DIE. * Back in modified_type_die, the call to lookup_type_die on the type passed to gen_type_die returns NULL. In the end, whole type trees, i.e. the ones referenced by DECL_ABSTRACT_ORIGIN attributes, are never referenced from type pruning "roots" and are thus pruned. The descriptive type at stake here is one of them, hence the assertion failure. This patch attemps to fix that with what seems to be the most sensible thing to do in my opinion: updating the "handle C typedef types" part in modified_type_die to check decl_ultimate_origin before calling gen_type_die: if that function returns something not null, then we know that gen_type_die/gen_typedef_die will not generate a DIE for the input type, so we try to process the ultimate origin instead. It also updates in a similar way gen_type_die_with_usage, assert that when gen_typedef_die is called on nodes that have an ultimate origin, this origin is themselves. gcc/ PR ada/79542 * dwarf2out.c (modified_type_die): For C typedef types that have an ultimate origin, process the ultimate origin instead of the input type. (gen_typedef_die): Assert that input DECLs have no ultimate origin. (gen_type_die_with_usage): For typedef variants that have an ultimate origin, just call gen_decl_die on the original DECL. (process_scope_var): Avoid creating DIEs for local typedefs and concrete static variables. gcc/testsuite/ PR ada/79542 * gnat.dg/debug13.ads, gnat.dg/debug13.adb: New testcase. Added: trunk/gcc/testsuite/gnat.dg/debug13.adb trunk/gcc/testsuite/gnat.dg/debug13.ads Modified: trunk/gcc/ChangeLog trunk/gcc/dwarf2out.c trunk/gcc/testsuite/ChangeLog
That's great, although it seems to only have been applied to TRUNK (gcc 8). I know it is too late for gcc 7.2, but this changeset should still be backported to the GCC 7.x branch as well.
The original updates by rguenth were lost by the bugzilla-wide data failure, and the rework only fixed the target milestone. I don't have permission to fix the missing data, so I'm going to paste the contents of the email received so someone else can: 8/14/2017 04:05 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Known to work| |8.0 Target Milestone|7.2 |7.3 Summary|[7/8 regression] ICE in |[7 regression] ICE in |add_gnat_descriptive_type_a |add_gnat_descriptive_type_a |ttribute |ttribute Known to fail| |7.2.0
Author: pmderodat Date: Tue Sep 5 11:04:41 2017 New Revision: 251709 URL: https://gcc.gnu.org/viewcvs?rev=251709&root=gcc&view=rev Log: [PR79542][Ada] Fix ICE in dwarf2out.c with nested func. inlining This is a backport from trunk. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79542 reports an ICE in dwarf2out.c for an Ada testcase built with optimization. This crash happens during the late generation pass because add_gnat_descriptive_type cannot find the type DIE corresponding to some descriptive type after having tried to generate it. This is because the DIE was generated during the early generation pass, but then pruned by the type pruning machinery. So why was it pruned? We are in a situation where we have cloned types (because of inlining, IIUC) whose TYPE_NAME have non-null DECL_ABSTRACT_ORIGIN attributes. As a consequence: * In modified_type_die, the "handle C typedef types" part calls gen_type_die on the cloned type. * gen_type_die matches a typedef variant, and then calls gen_decl_die on its TYPE_NAME, which will end up calling gen_typedef_die. * gen_typedef_die checks decl_ultimate_origin for this TYPE_DECL, and finds one, so it only adds a DW_AT_abstract_origin attribute to the DW_TAG_typedef DIE, but the cloned type itself does not get its own DIE. * Back in modified_type_die, the call to lookup_type_die on the type passed to gen_type_die returns NULL. In the end, whole type trees, i.e. the ones referenced by DECL_ABSTRACT_ORIGIN attributes, are never referenced from type pruning "roots" and are thus pruned. The descriptive type at stake here is one of them, hence the assertion failure. This patch attemps to fix that with what seems to be the most sensible thing to do in my opinion: updating the "handle C typedef types" part in modified_type_die to check decl_ultimate_origin before calling gen_type_die: if that function returns something not null, then we know that gen_type_die/gen_typedef_die will not generate a DIE for the input type, so we try to process the ultimate origin instead. It also updates in a similar way gen_type_die_with_usage, assert that when gen_typedef_die is called on nodes that have an ultimate origin, this origin is themselves. gcc/ PR ada/79542 * dwarf2out.c (modified_type_die): For C typedef types that have an ultimate origin, process the ultimate origin instead of the input type. (gen_typedef_die): Assert that input DECLs have no ultimate origin. (gen_type_die_with_usage): For typedef variants that have an ultimate origin, just call gen_decl_die on the original DECL. (process_scope_var): Avoid creating DIEs for local typedefs and concrete static variables. gcc/testsuite/ PR ada/79542 * gnat.dg/debug13.ads, gnat.dg/debug13.adb: New testcase. Added: branches/gcc-7-branch/gcc/testsuite/gnat.dg/debug13.adb branches/gcc-7-branch/gcc/testsuite/gnat.dg/debug13.ads Modified: branches/gcc-7-branch/gcc/ChangeLog branches/gcc-7-branch/gcc/dwarf2out.c branches/gcc-7-branch/gcc/testsuite/ChangeLog
I just merged the fix on the gcc-7 branch and tried to restore the change Richard did to this before the bug database backup restore.
Author: aldyh Date: Wed Sep 13 16:54:56 2017 New Revision: 252413 URL: https://gcc.gnu.org/viewcvs?rev=252413&root=gcc&view=rev Log: [PR79542][Ada] Fix ICE in dwarf2out.c with nested func. inlining https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79542 reports an ICE in dwarf2out.c for an Ada testcase built with optimization. This crash happens during the late generation pass because add_gnat_descriptive_type cannot find the type DIE corresponding to some descriptive type after having tried to generate it. This is because the DIE was generated during the early generation pass, but then pruned by the type pruning machinery. So why was it pruned? We are in a situation where we have cloned types (because of inlining, IIUC) whose TYPE_NAME have non-null DECL_ABSTRACT_ORIGIN attributes. As a consequence: * In modified_type_die, the "handle C typedef types" part calls gen_type_die on the cloned type. * gen_type_die matches a typedef variant, and then calls gen_decl_die on its TYPE_NAME, which will end up calling gen_typedef_die. * gen_typedef_die checks decl_ultimate_origin for this TYPE_DECL, and finds one, so it only adds a DW_AT_abstract_origin attribute to the DW_TAG_typedef DIE, but the cloned type itself does not get its own DIE. * Back in modified_type_die, the call to lookup_type_die on the type passed to gen_type_die returns NULL. In the end, whole type trees, i.e. the ones referenced by DECL_ABSTRACT_ORIGIN attributes, are never referenced from type pruning "roots" and are thus pruned. The descriptive type at stake here is one of them, hence the assertion failure. This patch attemps to fix that with what seems to be the most sensible thing to do in my opinion: updating the "handle C typedef types" part in modified_type_die to check decl_ultimate_origin before calling gen_type_die: if that function returns something not null, then we know that gen_type_die/gen_typedef_die will not generate a DIE for the input type, so we try to process the ultimate origin instead. It also updates in a similar way gen_type_die_with_usage, assert that when gen_typedef_die is called on nodes that have an ultimate origin, this origin is themselves. gcc/ PR ada/79542 * dwarf2out.c (modified_type_die): For C typedef types that have an ultimate origin, process the ultimate origin instead of the input type. (gen_typedef_die): Assert that input DECLs have no ultimate origin. (gen_type_die_with_usage): For typedef variants that have an ultimate origin, just call gen_decl_die on the original DECL. (process_scope_var): Avoid creating DIEs for local typedefs and concrete static variables. gcc/testsuite/ PR ada/79542 * gnat.dg/debug13.ads, gnat.dg/debug13.adb: New testcase. Added: branches/range-gen2/gcc/testsuite/gnat.dg/debug13.adb branches/range-gen2/gcc/testsuite/gnat.dg/debug13.ads Modified: branches/range-gen2/gcc/ChangeLog branches/range-gen2/gcc/dwarf2out.c branches/range-gen2/gcc/testsuite/ChangeLog