public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/61321] New: demangler crash on casts in template parameters
@ 2014-05-26 14:03 palves at redhat dot com
  2014-05-26 15:33 ` [Bug other/61321] " palves at redhat dot com
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: palves at redhat dot com @ 2014-05-26 14:03 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 61321
           Summary: demangler crash on casts in template parameters
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
          Assignee: unassigned at gcc dot gnu.org
          Reporter: palves at redhat dot com

The fix for bug 59195 (C++ demangler handles conversion operator incorrectly)
makes the demangler crash crash due to infinite recursion, in case of casts in
template parameters.  For example:

 template<int> struct A {};
 template <typename Y> void function_temp(A<sizeof ((Y)(999))>) {}
 template void function_temp<int>(A<sizeof (int)>);

The function_temp<int> instantiation  mangles to:
  _Z13function_tempIiEv1AIXszcvT_Li999EEE

The demangler parses this as:

typed name
  template
    name 'function_temp'
    template argument list
      builtin type int
  function type
    builtin type void
    argument list
      template
        name 'A'
        template argument list
          unary operator
            operator sizeof 
            unary operator
              cast
                template parameter 0
              literal
                builtin type int
                name '999'

And after this patch, when printing the template argument list of A (what
should be "<sizeof (int)>"), the template parameter 0 (that is, "T_") now
refers to the first parameter of the the template argument list of the 'A'
template, exactly what we were trying to print, while it should actually refer
to the first parameter of the 'function_temp' template.  This leads to infinite
recursion, and stack exaustion.

(This is particularly nasty for GDB, as it causes an immediate crash at
startup.)


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

* [Bug other/61321] demangler crash on casts in template parameters
  2014-05-26 14:03 [Bug other/61321] New: demangler crash on casts in template parameters palves at redhat dot com
@ 2014-05-26 15:33 ` palves at redhat dot com
  2014-05-26 16:40 ` palves at redhat dot com
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: palves at redhat dot com @ 2014-05-26 15:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Pedro Alves <palves at redhat dot com> ---
I think we need to distinguish conversion operators from expression casts.  

Working on a patch that adds:

--- c/include/demangle.h
+++ w/include/demangle.h
@@ -373,6 +373,10 @@ enum demangle_component_type
   /* A typecast, represented as a unary operator.  The one subtree is
      the type to which the argument should be cast.  */
   DEMANGLE_COMPONENT_CAST,
+  /* A conversion operator, represented as a unary operator.  The one
+     subtree is the type to which the argument should be converted
+     to.  */
+  DEMANGLE_COMPONENT_CONVERSION,


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

* [Bug other/61321] demangler crash on casts in template parameters
  2014-05-26 14:03 [Bug other/61321] New: demangler crash on casts in template parameters palves at redhat dot com
  2014-05-26 15:33 ` [Bug other/61321] " palves at redhat dot com
@ 2014-05-26 16:40 ` palves at redhat dot com
  2014-05-26 20:52 ` redi at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: palves at redhat dot com @ 2014-05-26 16:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Pedro Alves <palves at redhat dot com> ---
That worked.  Running bootstrap/tests.


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

* [Bug other/61321] demangler crash on casts in template parameters
  2014-05-26 14:03 [Bug other/61321] New: demangler crash on casts in template parameters palves at redhat dot com
  2014-05-26 15:33 ` [Bug other/61321] " palves at redhat dot com
  2014-05-26 16:40 ` palves at redhat dot com
@ 2014-05-26 20:52 ` redi at gcc dot gnu.org
  2014-05-27 12:00 ` palves at redhat dot com
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2014-05-26 20:52 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2014-05-26
           Assignee|unassigned at gcc dot gnu.org      |palves at redhat dot com
     Ever confirmed|0                           |1


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

* [Bug other/61321] demangler crash on casts in template parameters
  2014-05-26 14:03 [Bug other/61321] New: demangler crash on casts in template parameters palves at redhat dot com
                   ` (2 preceding siblings ...)
  2014-05-26 20:52 ` redi at gcc dot gnu.org
@ 2014-05-27 12:00 ` palves at redhat dot com
  2014-11-10 19:01 ` ccoutant at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: palves at redhat dot com @ 2014-05-27 12:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Pedro Alves <palves at redhat dot com> ---
https://gcc.gnu.org/ml/gcc-patches/2014-05/msg02279.html


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

* [Bug other/61321] demangler crash on casts in template parameters
  2014-05-26 14:03 [Bug other/61321] New: demangler crash on casts in template parameters palves at redhat dot com
                   ` (3 preceding siblings ...)
  2014-05-27 12:00 ` palves at redhat dot com
@ 2014-11-10 19:01 ` ccoutant at gcc dot gnu.org
  2014-11-10 19:19 ` ccoutant at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: ccoutant at gcc dot gnu.org @ 2014-11-10 19:01 UTC (permalink / raw)
  To: gcc-bugs

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

Cary Coutant <ccoutant at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |riku at multitaction dot com

--- Comment #4 from Cary Coutant <ccoutant at gcc dot gnu.org> ---
*** Bug 63425 has been marked as a duplicate of this bug. ***


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

* [Bug other/61321] demangler crash on casts in template parameters
  2014-05-26 14:03 [Bug other/61321] New: demangler crash on casts in template parameters palves at redhat dot com
                   ` (4 preceding siblings ...)
  2014-11-10 19:01 ` ccoutant at gcc dot gnu.org
@ 2014-11-10 19:19 ` ccoutant at gcc dot gnu.org
  2015-07-06  4:56 ` trippels at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: ccoutant at gcc dot gnu.org @ 2014-11-10 19:19 UTC (permalink / raw)
  To: gcc-bugs

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

Cary Coutant <ccoutant at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nheghathivhistha at gmail dot com

--- Comment #5 from Cary Coutant <ccoutant at gcc dot gnu.org> ---
*** Bug 63244 has been marked as a duplicate of this bug. ***


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

* [Bug other/61321] demangler crash on casts in template parameters
  2014-05-26 14:03 [Bug other/61321] New: demangler crash on casts in template parameters palves at redhat dot com
                   ` (5 preceding siblings ...)
  2014-11-10 19:19 ` ccoutant at gcc dot gnu.org
@ 2015-07-06  4:56 ` trippels at gcc dot gnu.org
  2015-07-06  5:14 ` trippels at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: trippels at gcc dot gnu.org @ 2015-07-06  4:56 UTC (permalink / raw)
  To: gcc-bugs

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

Markus Trippelsdorf <trippels at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |trippels at gcc dot gnu.org

--- Comment #6 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
*** Bug 65732 has been marked as a duplicate of this bug. ***


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

* [Bug other/61321] demangler crash on casts in template parameters
  2014-05-26 14:03 [Bug other/61321] New: demangler crash on casts in template parameters palves at redhat dot com
                   ` (6 preceding siblings ...)
  2015-07-06  4:56 ` trippels at gcc dot gnu.org
@ 2015-07-06  5:14 ` trippels at gcc dot gnu.org
  2015-07-14  9:39 ` palves at redhat dot com
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: trippels at gcc dot gnu.org @ 2015-07-06  5:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
Pedro could you please ping your patch?


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

* [Bug other/61321] demangler crash on casts in template parameters
  2014-05-26 14:03 [Bug other/61321] New: demangler crash on casts in template parameters palves at redhat dot com
                   ` (7 preceding siblings ...)
  2015-07-06  5:14 ` trippels at gcc dot gnu.org
@ 2015-07-14  9:39 ` palves at redhat dot com
  2015-07-27 10:09 ` trippels at gcc dot gnu.org
  2015-08-18 23:11 ` miyuki at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: palves at redhat dot com @ 2015-07-14  9:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Pedro Alves <palves at redhat dot com> ---
The patch was meanwhile approved:

 https://gcc.gnu.org/ml/gcc-patches/2014-11/msg01247.html

I'm afraid I won't have time to get back to this for at least a few weeks.
If someone else could push it, I'd appreciated it.


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

* [Bug other/61321] demangler crash on casts in template parameters
  2014-05-26 14:03 [Bug other/61321] New: demangler crash on casts in template parameters palves at redhat dot com
                   ` (8 preceding siblings ...)
  2015-07-14  9:39 ` palves at redhat dot com
@ 2015-07-27 10:09 ` trippels at gcc dot gnu.org
  2015-08-18 23:11 ` miyuki at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: trippels at gcc dot gnu.org @ 2015-07-27 10:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
*** Bug 63465 has been marked as a duplicate of this bug. ***


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

* [Bug other/61321] demangler crash on casts in template parameters
  2014-05-26 14:03 [Bug other/61321] New: demangler crash on casts in template parameters palves at redhat dot com
                   ` (9 preceding siblings ...)
  2015-07-27 10:09 ` trippels at gcc dot gnu.org
@ 2015-08-18 23:11 ` miyuki at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: miyuki at gcc dot gnu.org @ 2015-08-18 23:11 UTC (permalink / raw)
  To: gcc-bugs

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

Mikhail Maltsev <miyuki at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ian at airs dot com

--- Comment #10 from Mikhail Maltsev <miyuki at gcc dot gnu.org> ---
*** Bug 67261 has been marked as a duplicate of this bug. ***


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

end of thread, other threads:[~2015-08-18 23:11 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-26 14:03 [Bug other/61321] New: demangler crash on casts in template parameters palves at redhat dot com
2014-05-26 15:33 ` [Bug other/61321] " palves at redhat dot com
2014-05-26 16:40 ` palves at redhat dot com
2014-05-26 20:52 ` redi at gcc dot gnu.org
2014-05-27 12:00 ` palves at redhat dot com
2014-11-10 19:01 ` ccoutant at gcc dot gnu.org
2014-11-10 19:19 ` ccoutant at gcc dot gnu.org
2015-07-06  4:56 ` trippels at gcc dot gnu.org
2015-07-06  5:14 ` trippels at gcc dot gnu.org
2015-07-14  9:39 ` palves at redhat dot com
2015-07-27 10:09 ` trippels at gcc dot gnu.org
2015-08-18 23:11 ` miyuki 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).