diff options
author | weidendo <weidendo@a5019735-40e9-0310-863c-91ae7b9d1cf9> | 2009-06-29 16:13:25 +0000 |
---|---|---|
committer | weidendo <weidendo@a5019735-40e9-0310-863c-91ae7b9d1cf9> | 2009-06-29 16:13:25 +0000 |
commit | 48b24619b2e0518294c516e56490a77fa71d0f0b (patch) | |
tree | 723165165b71ef399d3e52bd022a34134010e696 | |
parent | 33e57a7bcf079398e9003f892a853037f9bd5de0 (diff) | |
download | valgrind-48b24619b2e0518294c516e56490a77fa71d0f0b.tar.gz |
Change demangler to not use excessive space from stack
Replaces alloca with xmalloc calls.
This should fix bug 197988.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10385 a5019735-40e9-0310-863c-91ae7b9d1cf9
-rw-r--r-- | coregrind/m_demangle/cp-demangle.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/coregrind/m_demangle/cp-demangle.c b/coregrind/m_demangle/cp-demangle.c index 00aba99d6..6db386c02 100644 --- a/coregrind/m_demangle/cp-demangle.c +++ b/coregrind/m_demangle/cp-demangle.c @@ -4426,16 +4426,11 @@ d_demangle_callback (const char *mangled, int options, cplus_demangle_init_info (mangled, options, strlen (mangled), &di); { -#ifdef CP_DYNAMIC_ARRAYS - __extension__ struct demangle_component comps[di.num_comps]; - __extension__ struct demangle_component *subs[di.num_subs]; - - di.comps = comps; - di.subs = subs; -#else - di.comps = alloca (di.num_comps * sizeof (*di.comps)); - di.subs = alloca (di.num_subs * sizeof (*di.subs)); -#endif + /* The original demangler uses alloca here with large allocations + for template-heavy code, e.g. when using Boost. This + is bad for Valgrind tools with limited stack size */ + di.comps = xmalloc(di.num_comps * sizeof (*di.comps)); + di.subs = xmalloc(di.num_subs * sizeof (*di.subs)); if (type) dc = cplus_demangle_type (&di); @@ -4456,6 +4451,9 @@ d_demangle_callback (const char *mangled, int options, status = (dc != NULL) ? cplus_demangle_print_callback (options, dc, callback, opaque) : 0; + + free(di.comps); + free(di.subs); } return status; |