tech-userlevel archive

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

Re: pthreads vs. overriden malloc



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 for the flags (see RW_THREAD in pthread_int.h and code
> in pthread_rwlock.c).

It may cause even more fallout, see 
src/external/gpl3/gcc.old/dist/gcc/tree-ssa-ccp.c


#if defined(__NetBSD__) && defined(NETBSD_NATIVE)
/*
 * This is a big, ugly, temporary hack:
 *    http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59958
 * To make sure we have configured all our targets correctly, mimic the
 * #ifdef cascade from src/lib/libc/stdlib/jemalloc.c here and compile
 * time assert that the value matches gcc's MALLOC_ABI_ALIGNMENT here.
 */

#if defined(__alpha__) || defined(__amd64__) || defined(__sparc64__)    \
     || (defined(__arm__) && defined(__ARM_EABI__)) \
     || defined(__ia64__) || defined(__powerpc__) \
     || ((defined(__mips__) || defined(__riscv__)) && defined(_LP64))
#define JEMALLOC_TINY_MIN_2POW  3
#endif


So the only "fix" is fixing the malloc override IMHO.

Martin


Home | Main Index | Thread Index | Old Index