public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Ian Lance Taylor <iant@google.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>,
	       GDB Patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH 1/3] Fix demangler testsuite crashes with CP_DEMANGLE_DEBUG defined
Date: Wed, 28 May 2014 22:20:00 -0000	[thread overview]
Message-ID: <53866119.9040305@redhat.com> (raw)
In-Reply-To: <CAKOQZ8x31NVqny_S085Y-XSkX3XguFAAh8K9ZQZRcJpsSsiAGg@mail.gmail.com>

+gdb-patches

On 05/27/2014 02:56 PM, Ian Lance Taylor wrote:
> On Tue, May 27, 2014 at 4:57 AM, Pedro Alves <palves@redhat.com> wrote:
>>
>> libiberty/
>> 2014-05-26  Pedro Alves  <palves@redhat.com>
>>
>>         * cp-demangle.c (d_dump): Handle DEMANGLE_COMPONENT_FUNCTION_PARAM
>>         and DEMANGLE_COMPONENT_NUMBER.
> 
> This is OK.

Thank you.  I've committed this to gcc svn, and pushed it to binutils-gdb
as well.

8<-------------
From: Pedro Alves <palves@redhat.com>
Subject: [PATCH] Fix demangler testsuite crashes with CP_DEMANGLE_DEBUG
 defined

Running the demangler's testsuite with CP_DEMANGLE_DEBUG defined
crashes, with:

 Program received signal SIGSEGV, Segmentation fault.
 0x000000000040a8c3 in d_dump (dc=0x1, indent=12) at ../../src/libiberty/cp-demangle.c:567
 567       switch (dc->type)

 (gdb) bt 3
 #0  0x000000000040a8c3 in d_dump (dc=0x1, indent=12) at ../../src/libiberty/cp-demangle.c:567
 #1  0x000000000040ae47 in d_dump (dc=0x7fffffffd098, indent=10) at ../../src/libiberty/cp-demangle.c:787
 #2  0x000000000040ae47 in d_dump (dc=0x7fffffffd0c8, indent=8) at ../../src/libiberty/cp-demangle.c:787

Note dc=0x1, which is obviously a bogus pointer.  This is the end of
d_dump recursing for a component type that that doesn't actually have
subtrees:

 787       d_dump (d_left (dc), indent + 2);
 788       d_dump (d_right (dc), indent + 2);

This fixes the two cases the testsuite currently trips on.

libiberty/
2014-05-28  Pedro Alves  <palves@redhat.com>

	* cp-demangle.c (d_dump): Handle DEMANGLE_COMPONENT_FUNCTION_PARAM
	and DEMANGLE_COMPONENT_NUMBER.
---
 libiberty/ChangeLog     | 5 +++++
 libiberty/cp-demangle.c | 6 ++++++
 2 files changed, 11 insertions(+)

diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index 7b25c7e..16eb6f7 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,8 @@
+2014-05-28  Pedro Alves  <palves@redhat.com>
+
+	* cp-demangle.c (d_dump): Handle DEMANGLE_COMPONENT_FUNCTION_PARAM
+	and DEMANGLE_COMPONENT_NUMBER.
+
 2014-05-22  Thomas Schwinge  <thomas@codesourcery.com>
 
 	* testsuite/demangle-expected: Fix last commit.
diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index 68d8ee1..c0d2ffe 100644
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -575,6 +575,9 @@ d_dump (struct demangle_component *dc, int indent)
     case DEMANGLE_COMPONENT_TEMPLATE_PARAM:
       printf ("template parameter %ld\n", dc->u.s_number.number);
       return;
+    case DEMANGLE_COMPONENT_FUNCTION_PARAM:
+      printf ("function parameter %ld\n", dc->u.s_number.number);
+      return;
     case DEMANGLE_COMPONENT_CTOR:
       printf ("constructor %d\n", (int) dc->u.s_ctor.kind);
       d_dump (dc->u.s_ctor.name, indent + 2);
@@ -760,6 +763,9 @@ d_dump (struct demangle_component *dc, int indent)
     case DEMANGLE_COMPONENT_CHARACTER:
       printf ("character '%c'\n",  dc->u.s_character.character);
       return;
+    case DEMANGLE_COMPONENT_NUMBER:
+      printf ("number %ld\n", dc->u.s_number.number);
+      return;
     case DEMANGLE_COMPONENT_DECLTYPE:
       printf ("decltype\n");
       break;
-- 
1.9.0

      reply	other threads:[~2014-05-28 22:20 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-27 11:57 [PATCH 0/3] mangler/demangler dogfooding Pedro Alves
2014-05-27 11:57 ` [PATCH 3/3] " Pedro Alves
2014-05-27 18:16   ` Mike Stump
2014-05-28 22:31   ` [PATCH v2 " Pedro Alves
2014-06-02 13:38     ` Jason Merrill
2014-05-27 11:57 ` [PATCH 2/3] PR other/61321 - demangler crash on casts in template parameters Pedro Alves
2014-05-30 17:37   ` Cary Coutant
2014-05-30 18:05     ` Ian Lance Taylor
2014-05-30 19:00       ` Pedro Alves
2014-06-02 13:42   ` Jason Merrill
2014-07-24 22:44     ` Cary Coutant
2014-07-25  9:55       ` Pedro Alves
2014-10-13 18:46         ` Cary Coutant
2014-11-10 21:45           ` Cary Coutant
2014-11-12 15:16             ` Jason Merrill
2014-05-27 11:57 ` [PATCH 1/3] Fix demangler testsuite crashes with CP_DEMANGLE_DEBUG defined Pedro Alves
2014-05-27 13:56   ` Ian Lance Taylor
2014-05-28 22:20     ` Pedro Alves [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53866119.9040305@redhat.com \
    --to=palves@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=iant@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).