public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] pidns13: Use getpid syscall directly instead of glibc wrapper
@ 2021-03-16  9:50 Yang Xu
  2021-03-16 10:15 ` Yang Xu
  0 siblings, 1 reply; 4+ messages in thread
From: Yang Xu @ 2021-03-16  9:50 UTC (permalink / raw)
  To: ltp

As clone(2) man-pages said "GNU C library versions 2.3.4 up to and including
2.24 contained a wrapper function for getpid(2) that performed caching of PIDs.
This caching relied on support in the glibc wrapper for clone(), but limitations
in the implementation meant that the cache was not up to date in some circumstances".

Because of the stale-cache problem, as well as other problems noted in getpid(2), the
PID caching feature was removed in glibc 2.25

To get the truth, always use getpid syscall instead of getting value from cache.
It fixes failure on centos7.

Reported-by: Feiyu Zhu <zhufy.jy@cn.fujitsu.com>
Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
---
 testcases/kernel/containers/pidns/pidns13.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testcases/kernel/containers/pidns/pidns13.c b/testcases/kernel/containers/pidns/pidns13.c
index 12aee917b..c27ef51b4 100644
--- a/testcases/kernel/containers/pidns/pidns13.c
+++ b/testcases/kernel/containers/pidns/pidns13.c
@@ -54,7 +54,7 @@ static void child_fn(unsigned int cinit_no)
 	pid_t pid, ppid;
 	int flags;
 
-	pid = getpid();
+	pid = tst_syscall(__NR_getpid);
 	ppid = getppid();
 	if (pid != CHILD_PID || ppid != PARENT_PID)
 		tst_brk(TBROK, "cinit%u: pidns not created.", cinit_no);
-- 
2.23.0




^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-03-17 10:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-16  9:50 [LTP] [PATCH] pidns13: Use getpid syscall directly instead of glibc wrapper Yang Xu
2021-03-16 10:15 ` Yang Xu
2021-03-17  7:01   ` Petr Vorel
2021-03-17 10:38     ` Petr Vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox