public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/91416] ICE in cp_check_const_attributes, at cp/decl2.c:1408
       [not found] <bug-91416-4@http.gcc.gnu.org/bugzilla/>
@ 2020-06-25 21:31 ` mpolacek at gcc dot gnu.org
  2021-04-03 22:21 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-06-25 21:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91416

--- Comment #10 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
*** Bug 95902 has been marked as a duplicate of this bug. ***

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

* [Bug c++/91416] ICE in cp_check_const_attributes, at cp/decl2.c:1408
       [not found] <bug-91416-4@http.gcc.gnu.org/bugzilla/>
  2020-06-25 21:31 ` [Bug c++/91416] ICE in cp_check_const_attributes, at cp/decl2.c:1408 mpolacek at gcc dot gnu.org
@ 2021-04-03 22:21 ` cvs-commit at gcc dot gnu.org
  2021-04-09 22:46 ` cvs-commit at gcc dot gnu.org
  2021-04-09 22:47 ` mpolacek at gcc dot gnu.org
  3 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-03 22:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91416

--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:a809d8a737da1ccebcd93065fc57fc0f4d94894a

commit r11-7975-ga809d8a737da1ccebcd93065fc57fc0f4d94894a
Author: Marek Polacek <polacek@redhat.com>
Date:   Fri Apr 2 17:11:32 2021 -0400

    c++: GC during late parsing collects live data [PR91416]

    Coming back to
    <https://gcc.gnu.org/pipermail/gcc-patches/2019-August/527699.html>:

    This is a crash that points to a GC problem.  Consider this test:

      __attribute__ ((unused)) struct S {
        S() { }
      } s;

    We're parsing a simple-declaration.  While parsing the decl specs, we parse
    the attribute, which means creating a TREE_LIST using ggc_alloc_*.

    A function body is a complete-class context so when parsing the
    member-specification of this class-specifier, we parse the bodies of the
    functions we'd queued in cp_parser_late_parsing_for_member.  This then
    leads to this call chain:
    cp_parser_function_definition_after_declarator -> expand_or_defer_fn ->
    expand_or_defer_fn_1 -> maybe_clone_body -> expand_or_defer_fn ->
    cgraph_node::finalize_function -> ggc_collect.

    In this test, the ggc_collect call collects the TREE_LIST we had
    allocated, and a crash duly ensues.

    I couldn't do what Richard suggested, that is, attach the attribute list
    to struct S, because we don't pass decl_specs from cp_parser_type_specifier
    down to cp_parser_class_specifier.  Therefore I've attempted to do "push
the
    decl_specifiers onto a vec that is a GC root", except I couldn't really
push
    the decl_specifiers, because first I'd have to mark cp_decl_specifier_seq
with
    GTY(()) and even that wouldn't be enough for me to be able to create

      static GTY(()) vec<cp_decl_specifier_seq *, va_gc>

    But here we only care about cp_decl_specifier_seq::attributes, so the
    patch is just this.  I've also extended the test so now we test a nested
    class too.

    gcc/cp/ChangeLog:

            PR c++/91416
            * parser.c: Create a GC root for attributes in a decl specifier.
            (cp_parser_type_specifier): Push/pop ->attributes onto/from it.

    gcc/testsuite/ChangeLog:

            PR c++/91416
            * g++.dg/other/gc7.C: New test.

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

* [Bug c++/91416] ICE in cp_check_const_attributes, at cp/decl2.c:1408
       [not found] <bug-91416-4@http.gcc.gnu.org/bugzilla/>
  2020-06-25 21:31 ` [Bug c++/91416] ICE in cp_check_const_attributes, at cp/decl2.c:1408 mpolacek at gcc dot gnu.org
  2021-04-03 22:21 ` cvs-commit at gcc dot gnu.org
@ 2021-04-09 22:46 ` cvs-commit at gcc dot gnu.org
  2021-04-09 22:47 ` mpolacek at gcc dot gnu.org
  3 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-09 22:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91416

--- Comment #12 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Marek Polacek
<mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:0d4128a514186ac5c41fde10085acb2dcc9118fd

commit r10-9690-g0d4128a514186ac5c41fde10085acb2dcc9118fd
Author: Marek Polacek <polacek@redhat.com>
Date:   Fri Apr 2 17:11:32 2021 -0400

    c++: GC during late parsing collects live data [PR91416]

    Coming back to
    <https://gcc.gnu.org/pipermail/gcc-patches/2019-August/527699.html>:

    This is a crash that points to a GC problem.  Consider this test:

      __attribute__ ((unused)) struct S {
        S() { }
      } s;

    We're parsing a simple-declaration.  While parsing the decl specs, we parse
    the attribute, which means creating a TREE_LIST using ggc_alloc_*.

    A function body is a complete-class context so when parsing the
    member-specification of this class-specifier, we parse the bodies of the
    functions we'd queued in cp_parser_late_parsing_for_member.  This then
    leads to this call chain:
    cp_parser_function_definition_after_declarator -> expand_or_defer_fn ->
    expand_or_defer_fn_1 -> maybe_clone_body -> expand_or_defer_fn ->
    cgraph_node::finalize_function -> ggc_collect.

    In this test, the ggc_collect call collects the TREE_LIST we had
    allocated, and a crash duly ensues.

    I couldn't do what Richard suggested, that is, attach the attribute list
    to struct S, because we don't pass decl_specs from cp_parser_type_specifier
    down to cp_parser_class_specifier.  Therefore I've attempted to do "push
the
    decl_specifiers onto a vec that is a GC root", except I couldn't really
push
    the decl_specifiers, because first I'd have to mark cp_decl_specifier_seq
with
    GTY(()) and even that wouldn't be enough for me to be able to create

      static GTY(()) vec<cp_decl_specifier_seq *, va_gc>

    But here we only care about cp_decl_specifier_seq::attributes, so the
    patch is just this.  I've also extended the test so now we test a nested
    class too.

    gcc/cp/ChangeLog:

            PR c++/91416
            * parser.c: Create a GC root for attributes in a decl specifier.
            (cp_parser_type_specifier): Push/pop ->attributes onto/from it.

    gcc/testsuite/ChangeLog:

            PR c++/91416
            * g++.dg/other/gc7.C: New test.

    (cherry picked from commit a809d8a737da1ccebcd93065fc57fc0f4d94894a)

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

* [Bug c++/91416] ICE in cp_check_const_attributes, at cp/decl2.c:1408
       [not found] <bug-91416-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2021-04-09 22:46 ` cvs-commit at gcc dot gnu.org
@ 2021-04-09 22:47 ` mpolacek at gcc dot gnu.org
  3 siblings, 0 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-04-09 22:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91416

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #13 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed in GCC 10.4 too.

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

end of thread, other threads:[~2021-04-09 22:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-91416-4@http.gcc.gnu.org/bugzilla/>
2020-06-25 21:31 ` [Bug c++/91416] ICE in cp_check_const_attributes, at cp/decl2.c:1408 mpolacek at gcc dot gnu.org
2021-04-03 22:21 ` cvs-commit at gcc dot gnu.org
2021-04-09 22:46 ` cvs-commit at gcc dot gnu.org
2021-04-09 22:47 ` mpolacek at gcc dot gnu.org

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).