Re: pthreads vs. overriden malloc

2017-09-12 Thread Martin Husemann
On Wed, Sep 13, 2017 at 02:23:22AM +0300, Valery Ushakov wrote: > Long story short... That program overrides malloc and returns memory > that is only 8 bytes aligned. That creates problems for our pthreads, > as rwlock code assumes that pthread_self() is 16-byte aligned and uses > the lower bits

Re: pthreads vs. overridden malloc

2017-09-12 Thread Valery Ushakov
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 ((uintp

pthreads vs. overriden malloc

2017-09-12 Thread Valery Ushakov
I just killed quite some time debugging a weird lockup I had with a third party program under NetBSD. Long story short... That program overrides malloc and returns memory that is only 8 bytes aligned. That creates problems for our pthreads, as rwlock code assumes that pthread_self() is 16-byte a