[PATCH, libbacktrace] Don't call __sync_lock_test_and_set if we don't have sync functions
John David Anglin
dave.anglin@bell.net
Sun Dec 30 16:28:00 GMT 2012
Ping.
On 9-Dec-12, at 2:08 PM, John David Anglin wrote:
> On hppa*-*-hpux*, we don't have sync functions. However,
> __sync_lock_test_and_set is called in backtrace_alloc and
> backtrace_free. This causes an abort before ICE proccessing
> is fully complete.
>
> hppa64 is an ELF target and backtraces are nominally supported.
>
> The attached change avoids calling __sync_lock_test_and_set
> if we don't have sync functions. As a result, the memory is
> leaked.
>
> This fixes the btest failure.
>
> OK for trunk?
>
> Dave
> --
> J. David Anglin dave.anglin@nrc-cnrc.gc.ca
> National Research Council of Canada (613) 990-0752
> (FAX: 952-6602)
>
> 2012-12-09 John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
>
> * mmap.c: Define HAVE_SYNC_FUNCTIONS if not defined.
> (backtrace_alloc): Don't call __sync_lock_test_and_set if we don't
> have sync functions.
> (backtrace_free): Likewise.
>
> Index: mmap.c
> ===================================================================
> --- mmap.c (revision 194055)
> +++ mmap.c (working copy)
> @@ -49,6 +49,10 @@
> #define MAP_ANONYMOUS MAP_ANON
> #endif
>
> +#ifndef HAVE_SYNC_FUNCTIONS
> +#define HAVE_SYNC_FUNCTIONS 0
> +#endif
> +
> /* A list of free memory blocks. */
>
> struct backtrace_freelist_struct
> @@ -96,7 +100,7 @@
> using mmap. __sync_lock_test_and_set returns the old state of
> the lock, so we have acquired it if it returns 0. */
>
> - if (!__sync_lock_test_and_set (&state->lock_alloc, 1))
> + if (HAVE_SYNC_FUNCTIONS && !__sync_lock_test_and_set (&state-
> >lock_alloc, 1))
> {
> for (pp = &state->freelist; *pp != NULL; pp = &(*pp)->next)
> {
> @@ -158,7 +162,7 @@
> If we can't acquire the lock, just leak the memory.
> __sync_lock_test_and_set returns the old state of the lock, so we
> have acquired it if it returns 0. */
> - if (!__sync_lock_test_and_set (&state->lock_alloc, 1))
> + if (HAVE_SYNC_FUNCTIONS && !__sync_lock_test_and_set (&state-
> >lock_alloc, 1))
> {
> backtrace_free_locked (state, addr, size);
>
>
--
John David Anglin dave.anglin@bell.net
More information about the Gcc-patches
mailing list