* C++ demangler fix
@ 2013-09-04 14:29 Gary Benson
2013-09-07 0:01 ` Jason Merrill
2013-09-10 15:49 ` Jakub Jelinek
0 siblings, 2 replies; 9+ messages in thread
From: Gary Benson @ 2013-09-04 14:29 UTC (permalink / raw)
To: gcc-patches; +Cc: DJ Delorie, Ian Lance Taylor
[-- Attachment #1: Type: text/plain, Size: 1157 bytes --]
Hi all,
d_print_comp maintains a certain amount of scope across calls (namely
a stack of templates) which is used when evaluating references in
template argument lists. If such a reference is later used from a
subtitution then the scope in force at the time of the substitution is
used. This appears to be wrong (I say appears because I couldn't find
anything in http://mentorembedded.github.io/cxx-abi/abi.html#mangling
to clarify this).
The attached patch causes the demangler to capture the scope the first
time such a reference is traversed, and to use that captured scope on
subsequent traversals. This fixes
http://sourceware.org/bugzilla/show_bug.cgi?id=14963 whereby a
reference is resolved against the wrong template, causing an infinite
loop and eventual stack overflow and segmentation fault.
I've added the result to the demangler test suite, but I know of
no way to check the validity of the demangled symbol other than by
inspection (and I am no expert here!) If anybody knows a way to
check this then please let me know! Otherwise, I hope this
not-really-checked demangled version is acceptable.
Thanks,
Gary
--
http://gbenson.net/
[-- Attachment #2: pr14963.patch --]
[-- Type: text/plain, Size: 12838 bytes --]
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index e4ce0b9..a084282 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,22 @@
+2013-09-04 Gary Benson <gbenson@redhat.com>
+
+ * cp-demangle.c: Include hashtab.h.
+ (struct d_print_info): New field saved_scopes.
+ (d_print_init): Initialize the above.
+ (d_print_free): New function.
+ (cplus_demangle_print_callback): Call the above.
+ (struct d_saved_scope): New structure.
+ (d_store_scope): New function.
+ (d_free_scope) Likewise.
+ (d_restore_scope) Likewise.
+ (d_hash_saved_scope) Likewise.
+ (d_equal_saved_scope) Likewise.
+ (d_print_comp): New variable saved_scope.
+ [DEMANGLE_COMPONENT_REFERENCE,
+ DEMANGLE_COMPONENT_RVALUE_REFERENCE]: Capture scope the first
+ time the component is traversed, and use the captured scope for
+ subsequent traversals.
+
2013-08-20 Alan Modra <amodra@gmail.com>
* floatformat.c (floatformat_ibm_long_double): Rename to..
diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index 70f5438..d44e82a 100644
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -128,6 +128,7 @@ extern char *alloca ();
#include "libiberty.h"
#include "demangle.h"
#include "cp-demangle.h"
+#include "hashtab.h"
/* If IN_GLIBCPP_V3 is defined, some functions are made static. We
also rename them via #define to avoid compiler errors when the
@@ -302,6 +303,10 @@ struct d_print_info
int pack_index;
/* Number of d_print_flush calls so far. */
unsigned long int flush_count;
+ /* Table mapping demangle components to scopes saved when first
+ traversing those components. These are used while evaluating
+ substitutions. */
+ htab_t saved_scopes;
};
#ifdef CP_DEMANGLE_DEBUG
@@ -3665,6 +3670,17 @@ d_print_init (struct d_print_info *dpi, demangle_callbackref callback,
dpi->opaque = opaque;
dpi->demangle_failure = 0;
+
+ dpi->saved_scopes = NULL;
+}
+
+/* Free a print information structure. */
+
+static void
+d_print_free (struct d_print_info *dpi)
+{
+ if (dpi->saved_scopes != NULL)
+ htab_delete (dpi->saved_scopes);
}
/* Indicate that an error occurred during printing, and test for error. */
@@ -3749,6 +3765,7 @@ cplus_demangle_print_callback (int options,
demangle_callbackref callback, void *opaque)
{
struct d_print_info dpi;
+ int success;
d_print_init (&dpi, callback, opaque);
@@ -3756,7 +3773,9 @@ cplus_demangle_print_callback (int options,
d_print_flush (&dpi);
- return ! d_print_saw_error (&dpi);
+ success = ! d_print_saw_error (&dpi);
+ d_print_free (&dpi);
+ return success;
}
/* Turn components into a human readable string. OPTIONS is the
@@ -3913,6 +3932,114 @@ d_print_subexpr (struct d_print_info *dpi, int options,
d_append_char (dpi, ')');
}
+/* A demangle component and some scope captured when it was first
+ traversed. */
+
+struct d_saved_scope
+{
+ /* The component whose scope this is. Used as the key for the
+ saved_scopes hashtable in d_print_info. May be NULL if this
+ scope will not be inserted into that table. */
+ const struct demangle_component *container;
+ /* Nonzero if the below items are copies and require freeing
+ when this scope is freed. */
+ int is_copy;
+ /* The list of templates, if any, that was current when this
+ scope was captured. */
+ struct d_print_template *templates;
+};
+
+/* Allocate a scope and populate it with the current values from DPI.
+ CONTAINER is the demangle component to which the scope refers, and
+ is used as the key for the saved_scopes hashtable in d_print_info.
+ CONTAINER may be NULL if this scope will not be inserted into that
+ table. If COPY is nonzero then items that may have been allocated
+ on the stack will be copied before storing. */
+
+static struct d_saved_scope *
+d_store_scope (const struct d_print_info *dpi,
+ const struct demangle_component *container, int copy)
+{
+ struct d_saved_scope *scope = XNEW (struct d_saved_scope);
+
+ scope->container = container;
+ scope->is_copy = copy;
+
+ if (copy)
+ {
+ struct d_print_template *ts, **tl = &scope->templates;
+
+ for (ts = dpi->templates; ts != NULL; ts = ts->next)
+ {
+ struct d_print_template *td = XNEW (struct d_print_template);
+
+ *tl = td;
+ tl = &td->next;
+ td->template_decl = ts->template_decl;
+ }
+ *tl = NULL;
+ }
+ else
+ scope->templates = dpi->templates;
+
+ return scope;
+}
+
+/* Free a scope allocated by d_store_scope. */
+
+static void
+d_free_scope (void *p)
+{
+ struct d_saved_scope *scope = (struct d_saved_scope *) p;
+
+ if (scope->is_copy)
+ {
+ struct d_print_template *ts, *tn;
+
+ for (ts = scope->templates; ts != NULL; ts = tn)
+ {
+ tn = ts->next;
+ free (ts);
+ }
+ }
+
+ free (scope);
+}
+
+/* Restore a stored scope to DPI, optionally freeing it afterwards. */
+
+static void
+d_restore_scope (struct d_print_info *dpi, struct d_saved_scope *scope,
+ int free_after)
+{
+ dpi->templates = scope->templates;
+
+ if (free_after)
+ d_free_scope (scope);
+}
+
+/* Returns a hash code for the saved scope referenced by p. */
+
+static hashval_t
+d_hash_saved_scope (const void *p)
+{
+ const struct d_saved_scope *s = (const struct d_saved_scope *) p;
+
+ return htab_hash_pointer (s->container);
+}
+
+/* Returns non-zero if the saved scopes referenced by p1 and p2
+ are equal. */
+
+static int
+d_equal_saved_scope (const void *p1, const void *p2)
+{
+ const struct d_saved_scope *s1 = (const struct d_saved_scope *) p1;
+ const struct d_saved_scope *s2 = (const struct d_saved_scope *) p2;
+
+ return s1->container == s2->container;
+}
+
/* Subroutine to handle components. */
static void
@@ -3923,6 +4050,10 @@ d_print_comp (struct d_print_info *dpi, int options,
without needing to modify *dc. */
const struct demangle_component *mod_inner = NULL;
+ /* Variable used to store the current scope while a previously
+ captured scope is used. */
+ struct d_saved_scope *saved_scope = NULL;
+
if (dc == NULL)
{
d_print_error (dpi);
@@ -4291,12 +4422,43 @@ d_print_comp (struct d_print_info *dpi, int options,
const struct demangle_component *sub = d_left (dc);
if (sub->type == DEMANGLE_COMPONENT_TEMPLATE_PARAM)
{
- struct demangle_component *a = d_lookup_template_argument (dpi, sub);
+ struct demangle_component *a;
+ struct d_saved_scope lookup;
+ void **slot;
+
+ if (dpi->saved_scopes == NULL)
+ dpi->saved_scopes = htab_create_alloc (1,
+ d_hash_saved_scope,
+ d_equal_saved_scope,
+ d_free_scope,
+ xcalloc, free);
+
+ lookup.container = sub;
+ slot = htab_find_slot (dpi->saved_scopes, &lookup, INSERT);
+ if (*slot == HTAB_EMPTY_ENTRY)
+ {
+ /* This is the first time SUB has been traversed.
+ We need to capture some scope so it can be
+ restored if SUB is reentered as a substitution. */
+ *slot = d_store_scope (dpi, sub, 1);
+ }
+ else
+ {
+ /* This traversal is reentering SUB as a substition.
+ Restore the original scope temporarily. */
+ saved_scope = d_store_scope (dpi, NULL, 0);
+ d_restore_scope (dpi, (struct d_saved_scope *) *slot, 0);
+ }
+
+ a = d_lookup_template_argument (dpi, sub);
if (a && a->type == DEMANGLE_COMPONENT_TEMPLATE_ARGLIST)
a = d_index_template_argument (a, dpi->pack_index);
if (a == NULL)
{
+ if (saved_scope != NULL)
+ d_restore_scope (dpi, saved_scope, 1);
+
d_print_error (dpi);
return;
}
@@ -4344,6 +4506,9 @@ d_print_comp (struct d_print_info *dpi, int options,
dpi->modifiers = dpm.next;
+ if (saved_scope != NULL)
+ d_restore_scope (dpi, saved_scope, 1);
+
return;
}
diff --git a/libiberty/testsuite/demangle-expected b/libiberty/testsuite/demangle-expected
index 1259e4a..d3a3603 100644
--- a/libiberty/testsuite/demangle-expected
+++ b/libiberty/testsuite/demangle-expected
@@ -4291,3 +4291,6 @@ void m<void () &&>(void (A::*)() &&)
--format=gnu-v3
_Z1nIM1AKFvvREEvT_
void n<void (A::*)() const &>(void (A::*)() const &)
+--format=gnu-v3
+_ZSt7forwardIRN1x14refobjiteratorINS0_3refINS0_4mime30multipart_section_processorObjIZ15get_body_parserIZZN14mime_processor21make_section_iteratorERKNS2_INS3_10sectionObjENS0_10ptrrefBaseEEEbENKUlvE_clEvEUlSB_bE_ZZNS6_21make_section_iteratorESB_bENKSC_clEvEUlSB_E0_ENS1_INS2_INS0_20outputrefiteratorObjIiEES8_EEEERKSsSB_OT_OT0_EUlmE_NS3_32make_multipart_default_discarderISP_EEEES8_EEEEEOT_RNSt16remove_referenceISW_E4typeE
+x::refobjiterator<x::ref<x::mime::multipart_section_processorObj<x::refobjiterator<x::ref<x::outputrefiteratorObj<int>, x::ptrrefBase> > get_body_parser<mime_processor::make_section_iterator(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)::{lambda()#1}::operator()() const::{lambda(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)#1}, mime_processor::make_section_iterator(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)::{lambda()#1}::operator()() const::{lambda(x::ref<x::mime::sectionObj, x::ptrrefBase> const&)#2}>(std::string const&, x::ref<x::mime::sectionObj, x::ptrrefBase> const&, mime_processor::make_section_iterator(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)::{lambda()#1}::operator()() const::{lambda(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)#1}&&, mime_processor::make_section_iterator(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)::{lambda()#1}::operator()() const::{lambda(x::ref<x::mime::sectionObj, x::ptrrefBase> const&)#2}&&)::{lambda(unsigned long)#1}, x::mime::make_multipart_default_discarder<mime_processor::make_section_iterator(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)::{lambda()#1}::operator()() const::{lambda(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)#1}&&> >, x::ptrrefBase> >& std::forward<x::refobjiterator<x::ref<x::mime::multipart_section_processorObj<x::refobjiterator<x::ref<x::outputrefiteratorObj<int>, x::ptrrefBase> > get_body_parser<mime_processor::make_section_iterator(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)::{lambda()#1}::operator()() const::{lambda(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)#1}, mime_processor::make_section_iterator(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)::{lambda()#1}::operator()() const::{lambda(x::ref<x::mime::sectionObj, x::ptrrefBase> const&)#2}>(std::string const&, x::ref<x::mime::sectionObj, x::ptrrefBase> const&, mime_processor::make_section_iterator(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)::{lambda()#1}::operator()() const::{lambda(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)#1}&&, mime_processor::make_section_iterator(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)::{lambda()#1}::operator()() const::{lambda(x::ref<x::mime::sectionObj, x::ptrrefBase> const&)#2}&&)::{lambda(unsigned long)#1}, x::mime::make_multipart_default_discarder<mime_processor::make_section_iterator(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)::{lambda()#1}::operator()() const::{lambda(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)#1}&&> >, x::ptrrefBase> >&>(std::remove_reference<x::mime::multipart_section_processorObj<x::refobjiterator<x::ref<x::outputrefiteratorObj<int>, x::ptrrefBase> > get_body_parser<mime_processor::make_section_iterator(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)::{lambda()#1}::operator()() const::{lambda(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)#1}, mime_processor::make_section_iterator(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)::{lambda()#1}::operator()() const::{lambda(x::ref<x::mime::sectionObj, x::ptrrefBase> const&)#2}>(std::string const&, x::ref<x::mime::sectionObj, x::ptrrefBase> const&, mime_processor::make_section_iterator(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)::{lambda()#1}::operator()() const::{lambda(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)#1}&&, mime_processor::make_section_iterator(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)::{lambda()#1}::operator()() const::{lambda(x::ref<x::mime::sectionObj, x::ptrrefBase> const&)#2}&&)::{lambda(unsigned long)#1}, x::mime::make_multipart_default_discarder<mime_processor::make_section_iterator(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)::{lambda()#1}::operator()() const::{lambda(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)#1}&&> > >::type&)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: C++ demangler fix
2013-09-04 14:29 C++ demangler fix Gary Benson
@ 2013-09-07 0:01 ` Jason Merrill
2013-09-07 0:58 ` Jason Merrill
2013-09-10 15:49 ` Jakub Jelinek
1 sibling, 1 reply; 9+ messages in thread
From: Jason Merrill @ 2013-09-07 0:01 UTC (permalink / raw)
To: gcc-patches, DJ Delorie, Ian Lance Taylor
OK, thanks.
Jason
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: C++ demangler fix
2013-09-07 0:01 ` Jason Merrill
@ 2013-09-07 0:58 ` Jason Merrill
0 siblings, 0 replies; 9+ messages in thread
From: Jason Merrill @ 2013-09-07 0:58 UTC (permalink / raw)
To: gcc-patches
OK, thanks.
Jason
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: C++ demangler fix
2013-09-04 14:29 C++ demangler fix Gary Benson
2013-09-07 0:01 ` Jason Merrill
@ 2013-09-10 15:49 ` Jakub Jelinek
2013-09-10 18:40 ` Paolo Carlini
2013-09-11 12:59 ` Gary Benson
1 sibling, 2 replies; 9+ messages in thread
From: Jakub Jelinek @ 2013-09-10 15:49 UTC (permalink / raw)
To: gcc-patches, DJ Delorie, Ian Lance Taylor
On Wed, Sep 04, 2013 at 03:29:43PM +0100, Gary Benson wrote:
> I've added the result to the demangler test suite, but I know of
> no way to check the validity of the demangled symbol other than by
> inspection (and I am no expert here!) If anybody knows a way to
> check this then please let me know! Otherwise, I hope this
> not-really-checked demangled version is acceptable.
Unfortunately this patch broke GCC bootstrap.
cp-demangle.c isn't used just in libiberty, where using hashtab,
xcalloc, XNEW etc. is fine, but also in libsupc++/libstdc++, where
none of that is fine. That is why cp-demangle.c only uses e.g. realloc,
checks for allocation failures and propagates those to the caller
if they happen (see allocation_failure field). hashtab.o isn't linked
into libstdc++ nor libsupc++, and the question is if we really do want to
link all the hashtable code into libstdc++.
How many hash table entries are there typically? Is a hashtable required?
> diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
> index e4ce0b9..a084282 100644
> --- a/libiberty/ChangeLog
> +++ b/libiberty/ChangeLog
> @@ -1,3 +1,22 @@
> +2013-09-04 Gary Benson <gbenson@redhat.com>
> +
> + * cp-demangle.c: Include hashtab.h.
> + (struct d_print_info): New field saved_scopes.
> + (d_print_init): Initialize the above.
> + (d_print_free): New function.
> + (cplus_demangle_print_callback): Call the above.
> + (struct d_saved_scope): New structure.
> + (d_store_scope): New function.
> + (d_free_scope) Likewise.
> + (d_restore_scope) Likewise.
> + (d_hash_saved_scope) Likewise.
> + (d_equal_saved_scope) Likewise.
> + (d_print_comp): New variable saved_scope.
> + [DEMANGLE_COMPONENT_REFERENCE,
> + DEMANGLE_COMPONENT_RVALUE_REFERENCE]: Capture scope the first
> + time the component is traversed, and use the captured scope for
> + subsequent traversals.
Jakub
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: C++ demangler fix
2013-09-10 15:49 ` Jakub Jelinek
@ 2013-09-10 18:40 ` Paolo Carlini
2013-09-10 18:52 ` Jakub Jelinek
2013-09-11 12:59 ` Gary Benson
1 sibling, 1 reply; 9+ messages in thread
From: Paolo Carlini @ 2013-09-10 18:40 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches, DJ Delorie, Ian Lance Taylor
Hi,
On 09/10/2013 05:34 PM, Jakub Jelinek wrote:
> On Wed, Sep 04, 2013 at 03:29:43PM +0100, Gary Benson wrote:
>> I've added the result to the demangler test suite, but I know of
>> no way to check the validity of the demangled symbol other than by
>> inspection (and I am no expert here!) If anybody knows a way to
>> check this then please let me know! Otherwise, I hope this
>> not-really-checked demangled version is acceptable.
> Unfortunately this patch broke GCC bootstrap.
> cp-demangle.c isn't used just in libiberty, where using hashtab,
> xcalloc, XNEW etc. is fine, but also in libsupc++/libstdc++, where
> none of that is fine. That is why cp-demangle.c only uses e.g. realloc,
> checks for allocation failures and propagates those to the caller
> if they happen (see allocation_failure field). hashtab.o isn't linked
> into libstdc++ nor libsupc++, and the question is if we really do want to
> link all the hashtable code into libstdc++.
> How many hash table entries are there typically? Is a hashtable required?
This is now bootstrap/58386. IMHO we should for the time being revert
the patch, the required modifications don't seem trivial.
Thanks,
Paolo.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: C++ demangler fix
2013-09-10 18:40 ` Paolo Carlini
@ 2013-09-10 18:52 ` Jakub Jelinek
2013-09-10 19:09 ` Paolo Carlini
0 siblings, 1 reply; 9+ messages in thread
From: Jakub Jelinek @ 2013-09-10 18:52 UTC (permalink / raw)
To: Paolo Carlini; +Cc: gcc-patches, DJ Delorie, Ian Lance Taylor
On Tue, Sep 10, 2013 at 08:36:02PM +0200, Paolo Carlini wrote:
> On 09/10/2013 05:34 PM, Jakub Jelinek wrote:
> >On Wed, Sep 04, 2013 at 03:29:43PM +0100, Gary Benson wrote:
> >>I've added the result to the demangler test suite, but I know of
> >>no way to check the validity of the demangled symbol other than by
> >>inspection (and I am no expert here!) If anybody knows a way to
> >>check this then please let me know! Otherwise, I hope this
> >>not-really-checked demangled version is acceptable.
> >Unfortunately this patch broke GCC bootstrap.
> >cp-demangle.c isn't used just in libiberty, where using hashtab,
> >xcalloc, XNEW etc. is fine, but also in libsupc++/libstdc++, where
> >none of that is fine. That is why cp-demangle.c only uses e.g. realloc,
> >checks for allocation failures and propagates those to the caller
> >if they happen (see allocation_failure field). hashtab.o isn't linked
> >into libstdc++ nor libsupc++, and the question is if we really do want to
> >link all the hashtable code into libstdc++.
> >How many hash table entries are there typically? Is a hashtable required?
> This is now bootstrap/58386. IMHO we should for the time being
> revert the patch, the required modifications don't seem trivial.
Agreed, can you please revert it?
Jakub
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: C++ demangler fix
2013-09-10 18:52 ` Jakub Jelinek
@ 2013-09-10 19:09 ` Paolo Carlini
0 siblings, 0 replies; 9+ messages in thread
From: Paolo Carlini @ 2013-09-10 19:09 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches, DJ Delorie, Ian Lance Taylor
On 09/10/2013 08:38 PM, Jakub Jelinek wrote
> Agreed, can you please revert it?
Sure, I'll do that momentarily.
Paolo.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: C++ demangler fix
2013-09-10 15:49 ` Jakub Jelinek
2013-09-10 18:40 ` Paolo Carlini
@ 2013-09-11 12:59 ` Gary Benson
2013-09-11 13:16 ` Jakub Jelinek
1 sibling, 1 reply; 9+ messages in thread
From: Gary Benson @ 2013-09-11 12:59 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches, DJ Delorie, Ian Lance Taylor
Jakub Jelinek wrote:
> cp-demangle.c isn't used just in libiberty, where using hashtab,
> xcalloc, XNEW etc. is fine, but also in libsupc++/libstdc++, where
> none of that is fine. That is why cp-demangle.c only uses
> e.g. realloc, checks for allocation failures and propagates those to
> the caller if they happen (see allocation_failure field). hashtab.o
> isn't linked into libstdc++ nor libsupc++, and the question is if we
> really do want to link all the hashtable code into libstdc++.
> How many hash table entries are there typically? Is a hashtable
> required?
Three entries were required for the symbol in the testcase:
"_ZSt7forwardIRN1x14refobjiteratorINS0_3refINS0_4mime30multipart_se" \
"ction_processorObjIZ15get_body_parserIZZN14mime_processor21make_se" \
"ction_iteratorERKNS2_INS3_10sectionObjENS0_10ptrrefBaseEEEbENKUlvE" \
"_clEvEUlSB_bE_ZZNS6_21make_section_iteratorESB_bENKSC_clEvEUlSB_E0" \
"_ENS1_INS2_INS0_20outputrefiteratorObjIiEES8_EEEERKSsSB_OT_OT0_EUl" \
"mE_NS3_32make_multipart_default_discarderISP_EEEES8_EEEEEOT_RNSt16" \
"remove_referenceISW_E4typeE"
I don't think there will many symbols with very many entries required.
I'm guessing that most symbols will require zero (which is why I made
it defer hashtable creation until it was required).
What kind of data structure would you like to see here, a realloc'd
array? Do libsupc++ and libstdc++ use the demangler for anything more
performance-sensitive than exception printing?
Thanks,
Gary
--
http://gbenson.net/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: C++ demangler fix
2013-09-11 12:59 ` Gary Benson
@ 2013-09-11 13:16 ` Jakub Jelinek
0 siblings, 0 replies; 9+ messages in thread
From: Jakub Jelinek @ 2013-09-11 13:16 UTC (permalink / raw)
To: gcc-patches, DJ Delorie, Ian Lance Taylor
On Wed, Sep 11, 2013 at 01:49:46PM +0100, Gary Benson wrote:
> Jakub Jelinek wrote:
> > cp-demangle.c isn't used just in libiberty, where using hashtab,
> > xcalloc, XNEW etc. is fine, but also in libsupc++/libstdc++, where
> > none of that is fine. That is why cp-demangle.c only uses
> > e.g. realloc, checks for allocation failures and propagates those to
> > the caller if they happen (see allocation_failure field). hashtab.o
> > isn't linked into libstdc++ nor libsupc++, and the question is if we
> > really do want to link all the hashtable code into libstdc++.
> > How many hash table entries are there typically? Is a hashtable
> > required?
>
> Three entries were required for the symbol in the testcase:
>
> "_ZSt7forwardIRN1x14refobjiteratorINS0_3refINS0_4mime30multipart_se" \
> "ction_processorObjIZ15get_body_parserIZZN14mime_processor21make_se" \
> "ction_iteratorERKNS2_INS3_10sectionObjENS0_10ptrrefBaseEEEbENKUlvE" \
> "_clEvEUlSB_bE_ZZNS6_21make_section_iteratorESB_bENKSC_clEvEUlSB_E0" \
> "_ENS1_INS2_INS0_20outputrefiteratorObjIiEES8_EEEERKSsSB_OT_OT0_EUl" \
> "mE_NS3_32make_multipart_default_discarderISP_EEEES8_EEEEEOT_RNSt16" \
> "remove_referenceISW_E4typeE"
>
> I don't think there will many symbols with very many entries required.
> I'm guessing that most symbols will require zero (which is why I made
> it defer hashtable creation until it was required).
>
> What kind of data structure would you like to see here, a realloc'd
> array? Do libsupc++ and libstdc++ use the demangler for anything more
> performance-sensitive than exception printing?
I don't know, I guess it isn't very performance sensitive, especially
if it is very rare to need too many of the scopes (at least on real-world
symbols, of course somebody can try to demangle something artificially
hacked up).
Jakub
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2013-09-11 12:59 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-04 14:29 C++ demangler fix Gary Benson
2013-09-07 0:01 ` Jason Merrill
2013-09-07 0:58 ` Jason Merrill
2013-09-10 15:49 ` Jakub Jelinek
2013-09-10 18:40 ` Paolo Carlini
2013-09-10 18:52 ` Jakub Jelinek
2013-09-10 19:09 ` Paolo Carlini
2013-09-11 12:59 ` Gary Benson
2013-09-11 13:16 ` Jakub Jelinek
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).