This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Handle PIEs in libbacktrace
- From: Ian Lance Taylor <iant at google dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Alexey Samsonov <samsonov at google dot com>, Dmitry Vyukov <dvyukov at google dot com>, Konstantin Serebryany <konstantin dot s dot serebryany at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 6 Dec 2013 06:40:52 -0800
- Subject: Re: [PATCH] Handle PIEs in libbacktrace
- Authentication-results: sourceware.org; auth=none
- References: <20131206075033 dot GE892 at tucnak dot redhat dot com> <CACT4Y+b4Txm5oWOCEC71OmU5+4sbxgpkx=6ziiXD7DPfBrpeoA at mail dot gmail dot com> <20131206082507 dot GF892 at tucnak dot redhat dot com> <CACT4Y+bn6bPbqcX4TghnQBKUe=JtVbxxrtKxA--z-5399hKUeg at mail dot gmail dot com> <CAGSYnCNgAB8G4mVFnA_TEkVyLKn2=ag_ef1ecrNn8HZTJtF1nw at mail dot gmail dot com> <20131206095337 dot GH892 at tucnak dot redhat dot com>
On Fri, Dec 6, 2013 at 1:53 AM, Jakub Jelinek <jakub@redhat.com> wrote:
>
> The alternative would be to just (perhaps under #ifdef SANITIZER_CP_DEMANGLE)
> compile in libiberty/cp-demangle.c (similarly how libstdc++ compiles it in)
> as part of libsanitizer/libiberty/ or even libsanitizer/libbacktrace/,
> and tweak it, so that like libsanitizer/libbacktrace it uses internal_memcpy
> etc. and uses InternalAlloc/InternalFree. The problem is that cp-demangle.c
> uses only realloc and free, and doesn't provide any hint on how large the
> previously allocated memory chunk is. So, either there is some easy way
> how to query the size of InternalAlloc returned allocation, or we would need
> to allocate uptr extra and store there number of bytes allocated
> and emulate realloc/free that way.
There was a recent buggy patch to the demangler that added calls to
malloc and realloc (2013-10-25 Gary Benson <gbenson@redhat.com>).
That patch must be fixed or reverted before the 4.9 release. The main
code in the demangler must not call malloc/realloc.
When that patch is fixed, you can use the cplus_demangle_v3_callback
function to get a demangler that never calls malloc.
Ian