[Top][All Lists]

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

Re: Pretest?

From: YAMAMOTO Mitsuharu
Subject: Re: Pretest?
Date: Thu, 15 Mar 2007 21:08:10 +0900 (JST)

>>>>> On Thu, 15 Mar 2007 12:04:33 +0100, Jan Djärv <address@hidden> said:

>> I suspect src/gmalloc.c, which does not provide thread-safe malloc
>> (correct me if I'm wrong), is used while HAVE_GTK_AND_PTHREAD is
>> defined.

> If src/gmalloc.c is used, then the hooks in alloc.c are used, so
> they should be thread safe.

No, alloc_mutex only protects the variables __malloc_hook etc., but
not for the heap itself.  Consider the following scenario:

  1) The main thread calls malloc.
  2) It then calls emacs_blocked_malloc via __malloc_hook.
  3) __malloc_hook is set to old_malloc_hook in emacs_blocked_malloc.
  4) Now the main thread is in execution of the original malloc.
  5) Another thread also calls malloc.
  6) The thread also executes the original malloc because
     __malloc_hook == old_malloc_hook.

                                     YAMAMOTO Mitsuharu

reply via email to

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