emacs-devel
[Top][All Lists]
Advanced

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

Re: address@hidden: Re: emacs-22.1 with GTK dumps core when Gnome wigets


From: Ken Raeburn
Subject: Re: address@hidden: Re: emacs-22.1 with GTK dumps core when Gnome wigets clicked]
Date: Mon, 25 Jun 2007 01:33:59 -0400

On Jun 21, 2007, at 06:13, Jan Djärv wrote:
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.

Nor is this change guaranteed to cause there to be only one access to "__malloc_hook", unless you change it to be declared volatile. (And, in fact, if you're optimizing, I would've expected it to be only one access in the original code on nearly all platforms.) Mutex protection around accesses to the hook variable would be the safest (and wouldn't require temporary variables or volatile qualifiers), though performance would not be as good.

Ken




reply via email to

[Prev in Thread] Current Thread [Next in Thread]