This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] malloc: Run fork handler as late as possible [BZ #19431]
- From: Florian Weimer <fweimer at redhat dot com>
- To: Andreas Schwab <schwab at suse dot de>
- Cc: Torvald Riegel <triegel at redhat dot com>, GNU C Library <libc-alpha at sourceware dot org>
- Date: Thu, 14 Apr 2016 12:56:46 +0200
- Subject: Re: [PATCH] malloc: Run fork handler as late as possible [BZ #19431]
- Authentication-results: sourceware.org; auth=none
- References: <56BBAF3D dot 5030905 at redhat dot com> <1455559833 dot 20971 dot 11 dot camel at localhost dot localdomain> <56C5EE32 dot 1020605 at redhat dot com> <1460485015 dot 3869 dot 267 dot camel at localhost dot localdomain> <570D4944 dot 7070501 at redhat dot com> <1460552111 dot 3869 dot 362 dot camel at localhost dot localdomain> <570E5362 dot 7070300 at redhat dot com> <mvmshyopjuv dot fsf at hawking dot suse dot de>
On 04/14/2016 12:26 PM, Andreas Schwab wrote:
Florian Weimer <fweimer@redhat.com> writes:
2016-04-13 Florian Weimer <fweimer@redhat.com>
[BZ #19431]
Run the malloc fork handler as late as possible to avoid deadlocks.
* malloc/malloc-internal.h: New file.
* malloc/malloc.c: Include it.
* malloc/arena.c (ATFORK_MEM): Remove.
(__malloc_fork_lock_parent): Rename from ptmalloc_lock_all.
Update comment.
(__malloc_fork_unlock_parent): Rename from ptmalloc_unlock_all.
(__malloc_fork_unlock_child): Rename from ptmalloc_unlock_all2.
Remove outdated comment.
(ptmalloc_init): Do not call thread_atfork. Remove
thread_atfork_static.
In file included from malloc.c:1889:0:
arena.c:139:1: error: conflicting types for '__malloc_fork_lock_parent'
__malloc_fork_lock_parent (void)
^
In file included from malloc.c:247:0:
../malloc/malloc-internal.h:23:6: note: previous declaration of '__malloc_fork_lock_parent' was here
void __malloc_fork_lock_parent (void) internal_function attribute_hidden;
^
Fixed with the attached patch. Sorry about that.
Florian
2016-04-14 Florian Weimer <fweimer@redhat.com>
* malloc/arena.c (__malloc_fork_lock_parent)
(__malloc_fork_unlock_parent, __malloc_fork_unlock_child): Add
internal_function attribute.
diff --git a/malloc/arena.c b/malloc/arena.c
index 8bf8171..1dd9dee 100644
--- a/malloc/arena.c
+++ b/malloc/arena.c
@@ -136,6 +136,7 @@ int __malloc_initialized = -1;
subsystem. */
void
+internal_function
__malloc_fork_lock_parent (void)
{
if (__malloc_initialized < 1)
@@ -156,6 +157,7 @@ __malloc_fork_lock_parent (void)
}
void
+internal_function
__malloc_fork_unlock_parent (void)
{
if (__malloc_initialized < 1)
@@ -172,6 +174,7 @@ __malloc_fork_unlock_parent (void)
}
void
+internal_function
__malloc_fork_unlock_child (void)
{
if (__malloc_initialized < 1)