This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 3/5] Add single-threaded path to _int_free


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]