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.