summaryrefslogtreecommitdiff
path: root/test/nptl/libatfork.c
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@uclibc-ng.org>2016-01-03 18:44:54 (GMT)
committerWaldemar Brodkorb <wbx@uclibc-ng.org>2016-01-06 22:54:38 (GMT)
commitd41cec56d5c04d88aa2d06986b692cd1fa279748 (patch)
tree0ae2816dabaff91329d1e51f1f234fc8ead55174 /test/nptl/libatfork.c
parent7b495396fbf7bf604939d8150955ce891f7e8ccd (diff)
pthread_atfork handlers not removed during dlclose
Invoke pthread_atfork handler cleanup when removing the associated DSO... If a program loads a DSO (dlopen) that sets up a pthread_atfork handler(s), and then subsequently closes the DSO, the handler(s) are left in place. If fork() is subsequently called, the handlers are invoked even though the DSO has been removed causing crashes or unpredictable code execution. This is because the code in __cxa_finalize(atexit.c)to invoke the unregister_atfork() routine is ifdef'd out with the comment that it hasn't been "looked into this yet...". Refs.: http://bugs.busybox.net/show_bug.cgi?id=8211 http://sourceware.org/bugzilla/show_bug.cgi?id=13502 Add test-case, enable cleanup for NPTL only. Signed-off-by: John Ata <john.ata@baesystems.com> Signed-off-by: Leonid Lisovskiy <lly.dev@gmail.com>
Diffstat (limited to 'test/nptl/libatfork.c')
-rw-r--r--test/nptl/libatfork.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/nptl/libatfork.c b/test/nptl/libatfork.c
new file mode 100644
index 0000000..f4ddca0
--- /dev/null
+++ b/test/nptl/libatfork.c
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <pthread.h>
+
+static void atfork_prepare(void)
+{
+ /* nothing to do */
+}
+
+static void atfork_parent(void)
+{
+ /* nothing to do */
+}
+
+static void atfork_child(void)
+{
+ /* nothing to do */
+}
+
+static __attribute__((constructor)) void init(void)
+{
+ pthread_atfork(atfork_prepare, atfork_parent, atfork_child);
+}
+
+static __attribute__((destructor)) void done(void)
+{
+ /* nothing to do */
+}