emacs-devel
[Top][All Lists]
Advanced

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

Re: Pretest?


From: Jan Djärv
Subject: Re: Pretest?
Date: Mon, 19 Mar 2007 09:00:10 +0100
User-agent: Thunderbird 1.5.0.10 (X11/20070302)



Jan Djärv skrev:


YAMAMOTO Mitsuharu skrev:
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.

You are correct. Can we, should we fix this, i.e. make gmalloc.c thread safe?


A thing to do after the release might be to synchronize with the thread safe malloc in glibc.

        Jan D.




reply via email to

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