This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 3/5] Add single-threaded path to _int_free
- From: DJ Delorie <dj at redhat dot com>
- To: Wilco Dijkstra <Wilco dot Dijkstra at arm dot com>
- Cc: libc-alpha at sourceware dot org, nd at arm dot com
- Date: Thu, 12 Oct 2017 16:29:39 -0400
- Subject: Re: [PATCH 3/5] Add single-threaded path to _int_free
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=dj at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9AE8EC04D28B
Wilco Dijkstra <Wilco.Dijkstra@arm.com> writes:
> @@ -4188,24 +4188,29 @@ _int_free (mstate av, mchunkptr p, int have_lock)
>
> /* Atomically link P to its fastbin: P->FD = *FB; *FB = P; */
> mchunkptr old = *fb, old2;
> - unsigned int old_idx = ~0u;
> - do
> +
> + /* Check that the top of the bin is not the record we are going to
> + add (i.e., double free). */
> + if (__builtin_expect (old == p, 0))
> + malloc_printerr ("double free or corruption (fasttop)");
By moving this out of the multi-thread loop, you're removing a check
against some of the top chunks in the case where the loop happens more
than once.
> + if (SINGLE_THREAD_P)
> {
If you set have_lock to zero here, you can omit the last two chunks of
this patch.