Bug 14232 - tst-cancel7 and tst-cancelx7 race condition
Summary: tst-cancel7 and tst-cancelx7 race condition
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: nptl (show other bugs)
Version: 2.15
: P2 normal
Target Milestone: 2.35
Assignee: Adhemerval Zanella
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-13 19:12 UTC by Joseph Myers
Modified: 2021-08-26 20:14 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Myers 2012-06-13 19:12:11 UTC
The test nptl/tst-cancel7 (and so tst-cancelx7) has a race condition that can cause failures with "could not read pid" in tst-cancel7.out.

Suppose the function sl waits a while between opening the output file and writing to it.  Then cancellation of that thread takes effect without the output having been written and flushed.  This can be reproduced reliably on x86_64 by inserting a delay loop, e.g.:

diff --git a/nptl/tst-cancel7.c b/nptl/tst-cancel7.c
index 0a972e6..efe46ef 100644
--- a/nptl/tst-cancel7.c
+++ b/nptl/tst-cancel7.c
@@ -42,6 +42,7 @@ tf (void *arg)
   return NULL;
 }
 
+volatile unsigned long long ll = 0;
 
 static void
 sl (void)
@@ -50,6 +51,9 @@ sl (void)
   if (f == NULL)
     exit (1);
 
+  for (ll = 0; ll < (1ULL << 34); ll++)
+    ;
+
   fprintf (f, "%lld\n", (long long) getpid ());
   fflush (f);
Comment 1 Adhemerval Zanella 2021-08-26 20:14:57 UTC
Fixed on 2.35.