From: Steve Muckle <smuckle.linux@gmail.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] lib/tst_test: avoid cleanup by cloned test threads
Date: Wed, 20 Sep 2017 13:23:06 -0700 [thread overview]
Message-ID: <20170920202306.170298-1-smuckle.linux@gmail.com> (raw)
Some versions of glibc and bionic report the same PID for parent and
child when clone() is called with CLONE_VM but not CLONE_THREAD. This
can cause cleanup to be incorrectly run by the child.
Avoid this by using a direct syscall for getpid when running the
cleanup.
Signed-off-by: Steve Muckle <smuckle.linux@gmail.com>
---
lib/tst_test.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/lib/tst_test.c b/lib/tst_test.c
index f72de82d4..0cc78589e 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -29,6 +29,7 @@
#include "tst_test.h"
#include "tst_device.h"
#include "lapi/futex.h"
+#include "lapi/syscalls.h"
#include "tst_ansi_color.h"
#include "tst_timer_test.h"
@@ -276,7 +277,13 @@ void tst_vbrk_(const char *file, const int lineno, int ttype,
{
print_result(file, lineno, ttype, fmt, va);
- if (getpid() == main_pid)
+ /*
+ * The getpid implementation in some C library versions may cause cloned
+ * test threads to show the same pid as their parent when CLONE_VM is
+ * specified but CLONE_THREAD is not. Use direct syscall to avoid
+ * cleanup running in the child.
+ */
+ if (syscall(SYS_getpid) == main_pid)
do_test_cleanup();
if (getpid() == lib_pid)
--
2.14.1.821.g8fa685d3b7-goog
next reply other threads:[~2017-09-20 20:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-20 20:23 Steve Muckle [this message]
2017-09-22 8:47 ` [LTP] [PATCH] lib/tst_test: avoid cleanup by cloned test threads Jan Stancek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170920202306.170298-1-smuckle.linux@gmail.com \
--to=smuckle.linux@gmail.com \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.