YAMAMOTO Mitsuharu skrev:
On Sun, 17 Jun 2007 17:49:28 -0400, Richard Stallman
<address@hidden> said:
Would someone else (other that Mitsuharu) please study this patch to
check whether it is really correct? Things like this can be tricky.
Please take a look at the following one instead. It tries to fix the
following problems of gmalloc.c with HAVE_GTK_AND_PTHREAD in Emacs
22.1.
* HAVE_GTK_AND_PTHREAD was checked before including config.h.
* malloc_initialize_1 called pthread_mutexattr_init that may call
malloc.
* _aligned_blocks was not protected.
* __malloc_hook etc. may be modified between its NULL-check and
the use.
The patch was corrupted by some mailer so I could not apply it, but:
! /* Copy the value of __malloc_hook to an automatic variable in
case
! __malloc_hook is modified in another thread between its
! NULL-check and the use. */
! hook = __malloc_hook;
! return (hook != NULL ? *hook : _malloc_internal) (size);
}
Assignment is not guaranteed to be atomic. It probably is on 32-
bit systems, but you should not assume it.