From patchwork Thu Aug 8 19:12:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 170830 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp8986270ile; Thu, 8 Aug 2019 12:13:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqx+FozW3VsL9H3r6lY+fMexZVCZmqIyQzub1n5XZkyBUdzgH0i16Ly6H1zaflc8mWMohPoJ X-Received: by 2002:a17:902:b18b:: with SMTP id s11mr10541752plr.220.1565291581017; Thu, 08 Aug 2019 12:13:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565291581; cv=none; d=google.com; s=arc-20160816; b=X8J51NiEL8ml0kBX+BP5rZ/ecjc4JmZGtoWTMRlfiCjdgyN+dc9EenKwRdxn4q2kTg zd8yeHP9bzQg1XkL5HLprdrcQs3GAyO8UdVsIkKSkadF1p7QUI436Blm6nKxCWqPD7KO dcwZxbCdS0DErYXdJnC4Sf1BqpO5ZUnLpR/38wzkifOvO9ifivrvb145aNvF9akMYIeN NdeCkeBaqu6hQ6IqedBMX6nlJvEWk6e+0HAfuHZ3j/MrDtK7Rufc12OUfY7tJ7/pnqv5 f0jKmIg630mQVXb9P17s6IQnVo3w/sJO7IwjQ2yN+TNdUoUiUlhM6QG/sIP+YUO+Lm+K F5rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:to:from:dkim-signature:delivered-to:sender :list-help:list-post:list-archive:list-subscribe:list-unsubscribe :list-id:precedence:mailing-list:dkim-signature:domainkey-signature; bh=larXO/W10iyEbgva0GWvBPAHMPCSb6DLk2DcOD58jT8=; b=hQm9794Ne5uxkEneSagqT9GeL7fPt4HpGiym11jmJ7o6Njvfw2+K+EveBvQ0E3BDMb m9JJhfIgQAFs6Sld7DlKFs/P1VgVs/+uOnLAXJQhQXKDMT3gfkI3qlBLgOz86y+yFKCS lBmEE7sp9//Qw8Tg0nJSmUmBHUdeR0dtPMOcYGR5Y0Wit8xJhOT+glRm+wmElUjZJRj0 9lhikaDsVash7W107o/bYpPl8rT3ZHVJNUPhAyqjQQOEBCJd8mRzTpMMrfuFo6M1J/wl XxB3SNrxnKkMxn1vP8fu7GABxhv1iDzk1lvUFtSQZoEOeot+Fy/A3FmElgaDLxqcLvWE 68aA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=Y5OFkDiy; dkim=pass header.i=@linaro.org header.s=google header.b=Wbbu3tqS; spf=pass (google.com: domain of libc-alpha-return-104235-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-104235-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id p93si2512171pjp.66.2019.08.08.12.13.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Aug 2019 12:13:01 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-104235-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=Y5OFkDiy; dkim=pass header.i=@linaro.org header.s=google header.b=Wbbu3tqS; spf=pass (google.com: domain of libc-alpha-return-104235-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-104235-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; q=dns; s= default; b=FOtpDZVZG0owZxkX7A8f08g8inBnml+BrhXWhKHcuNhQNnG2NnRPu wO346AClb8LxIxZIrfrpeKdt2gTIKNpvT7i2SAXumhcdCSgP3hc3iKcd4nZHlA89 biT+bAr9OV++4vgfBy+8jCj/nxvPtjEJbldTvH8dnQqAlrru2oosPA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; s=default; bh=msrvtv6chxmxSMAXD2mZXK6NkJ0=; b=Y5OFkDiy1atIGTmHZESCamgTwtpu bcvFBS+xGc2SNRBedEoTotAX5wOm/Bwb43hV7SJ8FIcDzkz2qfZ9pRzUB9wIvJ3q rSBVfaV4ExP8aBQC7GWjiM62lbOof8N/PLgWBMqb5Xcg2bIRrQXD3onLrRzrCxVF ODTCJia/sCk2Nuc= Received: (qmail 92003 invoked by alias); 8 Aug 2019 19:12:51 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 91995 invoked by uid 89); 8 Aug 2019 19:12:50 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-16.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=so, realworld, real-world X-HELO: mail-qt1-f179.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id; bh=larXO/W10iyEbgva0GWvBPAHMPCSb6DLk2DcOD58jT8=; b=Wbbu3tqSJ7KajxB7snaDs0WI22J5E/5qEAxvslSV5KU24o5rscOUkCGNkQbO46Fsdr ZLq8li9QHHI3FOa9z81k0AAiU1hKgymRJiZobKU66uENsvdy/sn7uijLOrYTk8Lm6M5R IjaePUuxg1Om04OBsKW9IjsRVDa38rov3XFGTYKoUqYMh278ze4dBQ1JGnt2g+qEM3/B xlwryy8KZaxg/2KvizGcEER4v2lV5ZatQmo+IgUo+a4qYzF1Qx6uS8Si3nBMmFnRgrPO GvEOU3kO+1HHM2VXVVXy6/HSMmzqSjoXRaww/xDHsy7I1zwXFS8F6X9+MzuOabs+kZdD dN2A== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2] nptl: Fix deadlock on atfork handler which calls dlclose (BZ#24595) Date: Thu, 8 Aug 2019 16:12:40 -0300 Message-Id: <20190808191240.7172-1-adhemerval.zanella@linaro.org> Changes from previous version: - Removed use of recursive lock in favor or release and re-acquire the lock when calling the atfork callback. --- Some real-world cases rely upon that atfork handlers can call functions that might change the atfork handlers, such as dlclose. Since 27761a10 (Refactor atfork handlers), all internal atfork handlers access is protected with a simple lock, not allowing reentrancy. This leads to deadlocks for the aforementioned scenario. Although this specific usage is far from portable (as comment #2 in the bug report), glibc did allow it in the past. This patch fixes by using a double-linked lists along with a lock release while calling the atfork handlers. This is similar to the strategy used on atexit. The list should be kept concise as long as it is invalid to dlclose itself. It should also be safe also call pthread_atfork from a registered callback, although it is up to the caller to handle the resulting list state regarding callback call. Since the new element is added on the end of the list, the prepare handler won't see the new element (since it ran in reverse order), however both the parent and child will. Checked on x86_64-linux-gnu and i686-linux-gnu. * misc/sys/queue.h (TAILQ_FOREACH_SAFE): New macro. * nptl/Makefile [build-shared == yes] (tests): Add tst-atfork3. (modules-names): Add tst-atfork3mod. (tst-atfork3mod.so-no-z-defs, $(objpfx)tst-atfork3:, LDFLAGS-tst-atfork3, $(objpfx)tst-atfork3mod.so, $(objpfx)tst-atfork3.out): New rules. * nptl/register-atfork.c: (__register_atfork, __unregister_atfork, __run_fork_handlers, libc_freeres_fn): Remove usage of dynarray in favor of a double linked list. (atfork_lock): Unlock before calling the callback. (fork_handlers_push_back, fork_handlers_remove, fork_handlers_remove_if, fork_handlers_remove_all): New functions. (fork_handler_list_find): Remove function. * nptl/tst-atfork3.c, nptl/tst-atfork3mod.c: New files. * sysdeps/nptl/fork.h (fork_handler): Remove definition. --- misc/sys/queue.h | 5 ++ nptl/Makefile | 10 ++- nptl/register-atfork.c | 159 +++++++++++++++++++++-------------------- nptl/tst-atfork3.c | 120 +++++++++++++++++++++++++++++++ nptl/tst-atfork3mod.c | 45 ++++++++++++ sysdeps/nptl/fork.h | 9 --- 6 files changed, 257 insertions(+), 91 deletions(-) create mode 100644 nptl/tst-atfork3.c create mode 100644 nptl/tst-atfork3mod.c -- 2.17.1 diff --git a/misc/sys/queue.h b/misc/sys/queue.h index daf4553d33..0187f298ce 100644 --- a/misc/sys/queue.h +++ b/misc/sys/queue.h @@ -437,6 +437,11 @@ struct { \ (var); \ (var) = ((var)->field.tqe_next)) +#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = ((head)->tqh_first); \ + (var) && ((tvar) = ((var))->field.tqe_next, 1); \ + (var) = (tvar)) + #define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \ (var); \ diff --git a/nptl/Makefile b/nptl/Makefile index 0567e77a79..3a61319789 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -396,7 +396,7 @@ tests += tst-cancelx2 tst-cancelx3 tst-cancelx4 tst-cancelx5 \ tst-oncex3 tst-oncex4 ifeq ($(build-shared),yes) tests += tst-atfork2 tst-tls4 tst-_res1 tst-fini1 tst-compat-forwarder \ - tst-audit-threads + tst-audit-threads tst-atfork3 tests-internal += tst-tls3 tst-tls3-malloc tst-tls5 tst-stackguard1 tests-nolibpthread += tst-fini1 ifeq ($(have-z-execstack),yes) @@ -409,13 +409,14 @@ modules-names = tst-atfork2mod tst-tls3mod tst-tls4moda tst-tls4modb \ tst-tls5modd tst-tls5mode tst-tls5modf tst-stack4mod \ tst-_res1mod1 tst-_res1mod2 tst-execstack-mod tst-fini1mod \ tst-join7mod tst-compat-forwarder-mod tst-audit-threads-mod1 \ - tst-audit-threads-mod2 + tst-audit-threads-mod2 tst-atfork3mod extra-test-objs += $(addsuffix .os,$(strip $(modules-names))) \ tst-cleanup4aux.o tst-cleanupx4aux.o test-extras += tst-cleanup4aux tst-cleanupx4aux test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(modules-names))) tst-atfork2mod.so-no-z-defs = yes +tst-atfork3mod.so-no-z-defs = yes tst-tls3mod.so-no-z-defs = yes tst-tls5mod.so-no-z-defs = yes tst-tls5moda.so-no-z-defs = yes @@ -552,9 +553,12 @@ tst-cancelx7-ARGS = $(tst-cancel7-ARGS) tst-umask1-ARGS = $(objpfx)tst-umask1.temp $(objpfx)tst-atfork2: $(libdl) $(shared-thread-library) +$(objpfx)tst-atfork3: $(libdl) $(shared-thread-library) LDFLAGS-tst-atfork2 = -rdynamic +LDFLAGS-tst-atfork3 = -rdynamic tst-atfork2-ENV = MALLOC_TRACE=$(objpfx)tst-atfork2.mtrace $(objpfx)tst-atfork2mod.so: $(shared-thread-library) +$(objpfx)tst-atfork3mod.so: $(shared-thread-library) tst-stack3-ENV = MALLOC_TRACE=$(objpfx)tst-stack3.mtrace $(objpfx)tst-stack3-mem.out: $(objpfx)tst-stack3.out @@ -654,7 +658,7 @@ $(addprefix $(objpfx), $(tests-reverse)): \ $(objpfx)../libc.so: $(common-objpfx)libc.so ; $(addprefix $(objpfx),$(tests-static) $(xtests-static)): $(objpfx)libpthread.a -$(objpfx)tst-atfork2.out: $(objpfx)tst-atfork2mod.so +$(objpfx)tst-atfork3.out: $(objpfx)tst-atfork3mod.so else $(addprefix $(objpfx),$(tests) $(test-srcs)): $(objpfx)libpthread.a endif diff --git a/nptl/register-atfork.c b/nptl/register-atfork.c index 80a1becb5f..3e7b40024e 100644 --- a/nptl/register-atfork.c +++ b/nptl/register-atfork.c @@ -20,131 +20,132 @@ #include #include #include -#include -#define DYNARRAY_ELEMENT struct fork_handler -#define DYNARRAY_STRUCT fork_handler_list -#define DYNARRAY_PREFIX fork_handler_list_ -#define DYNARRAY_INITIAL_SIZE 48 -#include - -static struct fork_handler_list fork_handlers; -static bool fork_handler_init = false; +#include +struct fork_handler +{ + TAILQ_ENTRY (fork_handler) qe; + void (*prepare_handler) (void); + void (*parent_handler) (void); + void (*child_handler) (void); + void *dso_handle; +}; + +typedef TAILQ_HEAD (fork_handler_list, fork_handler) fork_handler_list; +static fork_handler_list fork_handlers = TAILQ_HEAD_INITIALIZER (fork_handlers); static int atfork_lock = LLL_LOCK_INITIALIZER; int __register_atfork (void (*prepare) (void), void (*parent) (void), void (*child) (void), void *dso_handle) { - lll_lock (atfork_lock, LLL_PRIVATE); + struct fork_handler *entry = malloc (sizeof (struct fork_handler)); + if (entry == NULL) + return ENOMEM; - if (!fork_handler_init) - { - fork_handler_list_init (&fork_handlers); - fork_handler_init = true; - } + entry->prepare_handler = prepare; - struct fork_handler *newp = fork_handler_list_emplace (&fork_handlers); - if (newp != NULL) - { - newp->prepare_handler = prepare; - newp->parent_handler = parent; - newp->child_handler = child; - newp->dso_handle = dso_handle; - } + entry->parent_handler = parent; + entry->child_handler = child; + entry->dso_handle = dso_handle; - /* Release the lock. */ + lll_lock (atfork_lock, LLL_PRIVATE); + TAILQ_INSERT_TAIL (&fork_handlers, entry, qe); lll_unlock (atfork_lock, LLL_PRIVATE); - return newp == NULL ? ENOMEM : 0; + return 0; } libc_hidden_def (__register_atfork) -static struct fork_handler * -fork_handler_list_find (struct fork_handler_list *fork_handlers, - void *dso_handle) -{ - for (size_t i = 0; i < fork_handler_list_size (fork_handlers); i++) - { - struct fork_handler *elem = fork_handler_list_at (fork_handlers, i); - if (elem->dso_handle == dso_handle) - return elem; - } - return NULL; -} - void __unregister_atfork (void *dso_handle) { - lll_lock (atfork_lock, LLL_PRIVATE); + fork_handler_list temp_list = TAILQ_HEAD_INITIALIZER (temp_list); + struct fork_handler *it, *it1; - struct fork_handler *first = fork_handler_list_find (&fork_handlers, - dso_handle); - /* Removing is done by shifting the elements in the way the elements - that are not to be removed appear in the beginning in dynarray. - This avoid the quadradic run-time if a naive strategy to remove and - shift one element at time. */ - if (first != NULL) + lll_lock (atfork_lock, LLL_PRIVATE); + TAILQ_FOREACH_SAFE (it, &fork_handlers, qe, it1) { - struct fork_handler *new_end = first; - first++; - for (; first != fork_handler_list_end (&fork_handlers); ++first) + if (it->dso_handle == dso_handle) { - if (first->dso_handle != dso_handle) - { - *new_end = *first; - ++new_end; - } + TAILQ_REMOVE (&fork_handlers, it, qe); + TAILQ_INSERT_TAIL (&temp_list, it, qe); } + } + lll_unlock (atfork_lock, LLL_PRIVATE); - ptrdiff_t removed = first - new_end; - for (size_t i = 0; i < removed; i++) - fork_handler_list_remove_last (&fork_handlers); + while ((it = TAILQ_FIRST (&temp_list)) != NULL) + { + TAILQ_REMOVE (&temp_list, it, qe); + free (it); } +} - lll_unlock (atfork_lock, LLL_PRIVATE); +static inline void +lock_atfork (_Bool do_locking) +{ + if (do_locking) + lll_lock (atfork_lock, LLL_PRIVATE); +} + +static inline void +unlock_atfork (_Bool do_locking) +{ + if (do_locking) + lll_unlock (atfork_lock, LLL_PRIVATE); } void __run_fork_handlers (enum __run_fork_handler_type who, _Bool do_locking) { - struct fork_handler *runp; + struct fork_handler *it; if (who == atfork_run_prepare) { - if (do_locking) - lll_lock (atfork_lock, LLL_PRIVATE); - size_t sl = fork_handler_list_size (&fork_handlers); - for (size_t i = sl; i > 0; i--) + lock_atfork (do_locking); + TAILQ_FOREACH_REVERSE (it, &fork_handlers, fork_handler_list, qe) { - runp = fork_handler_list_at (&fork_handlers, i - 1); - if (runp->prepare_handler != NULL) - runp->prepare_handler (); + if (it->prepare_handler != NULL) + { + /* Unlock the list while we call a foreign function. */ + unlock_atfork (do_locking); + it->prepare_handler (); + lock_atfork (do_locking); + } } } else { - size_t sl = fork_handler_list_size (&fork_handlers); - for (size_t i = 0; i < sl; i++) + TAILQ_FOREACH (it, &fork_handlers, qe) { - runp = fork_handler_list_at (&fork_handlers, i); - if (who == atfork_run_child && runp->child_handler) - runp->child_handler (); - else if (who == atfork_run_parent && runp->parent_handler) - runp->parent_handler (); + /* Unlock the list while we call a foreign function. */ + if (who == atfork_run_child && it->child_handler) + { + unlock_atfork (do_locking); + it->child_handler (); + lock_atfork (do_locking); + } + else if (who == atfork_run_parent && it->parent_handler) + { + unlock_atfork (do_locking); + it->parent_handler (); + lock_atfork (do_locking); + } } - if (do_locking) - lll_unlock (atfork_lock, LLL_PRIVATE); + unlock_atfork (do_locking); } } - libc_freeres_fn (free_mem) { - lll_lock (atfork_lock, LLL_PRIVATE); - - fork_handler_list_free (&fork_handlers); + struct fork_handler *it, *it1; + lll_lock (atfork_lock, LLL_PRIVATE); + TAILQ_FOREACH_SAFE (it, &fork_handlers, qe, it1) + { + TAILQ_REMOVE (&fork_handlers, it, qe); + free (it); + } lll_unlock (atfork_lock, LLL_PRIVATE); } diff --git a/nptl/tst-atfork3.c b/nptl/tst-atfork3.c new file mode 100644 index 0000000000..466a5933c1 --- /dev/null +++ b/nptl/tst-atfork3.c @@ -0,0 +1,120 @@ +/* Check if pthread_atfork handler can call dlclose (BZ#24595) + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +/* Check if pthread_atfork handlers do not deadlock when calling a function + that might alter the internal fork handle list, such as dlclose. + + The test registers a callback set with pthread_atfork(), dlopen() a shared + library (nptl/tst-atfork3mod.c), calls an exported symbol from the library + (which in turn also registers atfork handlers), and calls fork to trigger + the callbacks. */ + +static void *handler; +static bool run_dlclose_prepare; +static bool run_dlclose_parent; +static bool run_dlclose_child; + +static void +prepare (void) +{ + if (run_dlclose_prepare) + TEST_COMPARE (dlclose (handler), 0); +} + +static void +parent (void) +{ + if (run_dlclose_parent) + TEST_COMPARE (dlclose (handler), 0); +} + +static void +child (void) +{ + if (run_dlclose_child) + TEST_COMPARE (dlclose (handler), 0); +} + +static void +proc_func (void *closure) +{ +} + +static void +do_test_generic (bool dlclose_prepare, bool dlclose_parent, bool dlclose_child) +{ + run_dlclose_prepare = dlclose_prepare; + run_dlclose_parent = dlclose_parent; + run_dlclose_child = dlclose_child; + + handler = dlopen ("tst-atfork3mod.so", RTLD_NOW); + TEST_VERIFY (handler != NULL); + + int (*atfork3mod_func)(void); + atfork3mod_func = dlsym (handler, "atfork3mod_func"); + TEST_VERIFY (atfork3mod_func != NULL); + + atfork3mod_func (); + + struct support_capture_subprocess proc + = support_capture_subprocess (proc_func, NULL); + support_capture_subprocess_check (&proc, "tst-atfork3", 0, sc_allow_none); + + handler = atfork3mod_func = NULL; + + support_capture_subprocess_free (&proc); +} + +static void * +thread_func (void *closure) +{ + return NULL; +} + +static int +do_test (void) +{ + { + /* Make the process acts as multithread. */ + pthread_attr_t attr; + xpthread_attr_init (&attr); + xpthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED); + xpthread_create (&attr, thread_func, NULL); + } + + TEST_COMPARE (pthread_atfork (prepare, parent, child), 0); + + do_test_generic (true /* prepare */, false /* parent */, false /* child */); + do_test_generic (false /* prepare */, true /* parent */, false /* child */); + do_test_generic (false /* prepare */, false /* parent */, true /* child */); + + return 0; +} + +#include diff --git a/nptl/tst-atfork3mod.c b/nptl/tst-atfork3mod.c new file mode 100644 index 0000000000..7449962e57 --- /dev/null +++ b/nptl/tst-atfork3mod.c @@ -0,0 +1,45 @@ +/* Copyright (C) 2003-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2003. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +#include + +static void +mod_prepare (void) +{ +} + +static void +mod_parent (void) +{ +} + +static void +mod_child (void) +{ +} + +int atfork3mod_func (void) +{ + TEST_COMPARE (pthread_atfork (mod_prepare, mod_parent, mod_child), 0); + + return 0; +} diff --git a/sysdeps/nptl/fork.h b/sysdeps/nptl/fork.h index 99ed76034b..cda22158d8 100644 --- a/sysdeps/nptl/fork.h +++ b/sysdeps/nptl/fork.h @@ -24,15 +24,6 @@ extern unsigned long int __fork_generation attribute_hidden; /* Pointer to the fork generation counter in the thread library. */ extern unsigned long int *__fork_generation_pointer attribute_hidden; -/* Elements of the fork handler lists. */ -struct fork_handler -{ - void (*prepare_handler) (void); - void (*parent_handler) (void); - void (*child_handler) (void); - void *dso_handle; -}; - /* Function to call to unregister fork handlers. */ extern void __unregister_atfork (void *dso_handle) attribute_hidden; #define UNREGISTER_ATFORK(dso_handle) __unregister_atfork (dso_handle)