tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: pthreads vs. overridden malloc



On Wed, Sep 13, 2017 at 02:23:22 +0300, Valery Ushakov wrote:

> The two approaches I can think of are to use posix_memalign+memset
> instead of calloc and to use calloc and manually re-align the result.
> 
> So either
> 
>     newthread = calloc(1, __pthread_st_size + ~RW_THREAD);
>     if ((uintptr_t)newthread & ~RW_THREAD) {
>         newthread = (pthread_t)(((uintptr_t)(newthread)
>                                  + ~RW_THREAD) & RW_THREAD);
>     }

As someone kindly pointed out privately, this has the problem of
losing the original pointer.  Sorry, I posted still in the heat of the
(rather long) chase.

-uwe


Home | Main Index | Thread Index | Old Index