This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch RFC: Use internal qsort function in libbacktrace
- From: Rainer Orth <ro at CeBiTec dot Uni-Bielefeld dot DE>
- To: Paolo Carlini <paolo dot carlini at oracle dot com>
- Cc: Ian Lance Taylor <iant at google dot com>, gcc-patches at gcc dot gnu dot org
- Date: Fri, 07 Mar 2014 13:12:02 +0100
- Subject: Re: Patch RFC: Use internal qsort function in libbacktrace
- Authentication-results: sourceware.org; auth=none
- References: <mcrppm1mi78 dot fsf at iant-glaptop dot roam dot corp dot google dot com> <5319AEB2 dot 6040300 at oracle dot com>
Hi Paolo,
> On 03/05/2014 04:34 AM, Ian Lance Taylor wrote:
>> The GNU glibc qsort function will call malloc in some cases. That makes
>> it unsuitable for libbacktrace, which is intended to work when called
>> from a signal handler. This patch changes libbacktrace to use an
>> internal qsort function.
>>
>> I'm posting this for comments in case anybody sees anything wrong with
>> the implementation. I'll commit it in a day or two if I don't hear
>> anything.
>>
>> Bootstrapped and ran libbacktrace and Go tests on
>> x86_64-unknown-linux-gnu.
> Sorry if I missed some messages or I'm just confused, but today I'm seeing
> a lot of regressions all of the same form:
>
> libsanitizer/asan/.libs/libasan.so: undefined reference to `backtrace_qsort'
>
> Confirmed in eg:
>
> http://gcc.gnu.org/ml/gcc-testresults/2014-03/msg00399.html
>
> Any idea what's up?
I suspect the following patch (yet untested) will fix this:
2014-03-07 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* libbacktrace/Makefile.am (libsanitizer_libbacktrace_la_SOURCES):
Add ../../libbacktrace/sort.c.
* libbacktrace/Makefile.in: Regenerate.
* libbacktrace/backtrace-rename.h (backtrace_qsort): Define.
# HG changeset patch
# Parent 4cf44f327506e7ae03a9bdecee301cddc2cb29b3
Handle backtrace_qsort
diff --git a/libsanitizer/libbacktrace/Makefile.am b/libsanitizer/libbacktrace/Makefile.am
--- a/libsanitizer/libbacktrace/Makefile.am
+++ b/libsanitizer/libbacktrace/Makefile.am
@@ -50,6 +50,7 @@ libsanitizer_libbacktrace_la_SOURCES = \
../../libbacktrace/fileline.c \
../../libbacktrace/internal.h \
../../libbacktrace/posix.c \
+ ../../libbacktrace/sort.c \
../../libbacktrace/state.c \
../../libiberty/cp-demangle.c \
bridge.cc
diff --git a/libsanitizer/libbacktrace/backtrace-rename.h b/libsanitizer/libbacktrace/backtrace-rename.h
--- a/libsanitizer/libbacktrace/backtrace-rename.h
+++ b/libsanitizer/libbacktrace/backtrace-rename.h
@@ -8,6 +8,7 @@
#define backtrace_initialize __asan_backtrace_initialize
#define backtrace_open __asan_backtrace_open
#define backtrace_pcinfo __asan_backtrace_pcinfo
+#define backtrace_qsort __asan_backtrace_qsort
#define backtrace_release_view __asan_backtrace_release_view
#define backtrace_syminfo __asan_backtrace_syminfo
#define backtrace_vector_finish __asan_backtrace_vector_finish
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University