This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: A few race conditions in the testsuite


Hi Howard,

I detected this on ppc-darwin actually. And it is sporadic. Sometimes passes, sometimes fails. Due to an unrelated OS bug, sometimes the failure resulted in a hang, which is how it originally got detected in the first place. To reliably detect this one you have to add a std::cout << "Pass\n" to the parent process and build it separately, and then try it several times (at least that was what I did).

Ah, ah, thanks for the additional info. This bug is very difficult to trigger, normally.


Anyway, I'm applying the below. For the next contributions:
1- Preferably, attach the patch, don't send it inline in the body of the message (in this case, for example, I was unable to extract it ("malformed at line 18") and had to reconstruct it).
2- Don't send the ChangeLog as a diff, in matter of ours doesn't apply cleanly anymore.
3- Update the Copyrights... you know that ;)


Thanks!

Paolo.

///////////////////
2006-03-12  Howard Hinnant  <hhinnant@apple.com>

	* testsuite/27_io/basic_filebuf/underflow/char/10097.cc:
	Fix race condition.
	* testsuite/27_io/objects/char/9661-1.cc: Likewise.
	* testsuite/27_io/objects/wchar_t/9661-1.cc: Likewise.
Index: testsuite/27_io/objects/wchar_t/9661-1.cc
===================================================================
--- testsuite/27_io/objects/wchar_t/9661-1.cc	(revision 111977)
+++ testsuite/27_io/objects/wchar_t/9661-1.cc	(working copy)
@@ -3,7 +3,7 @@
 
 // 2003-04-30  Petur Runolfsson <peturr02@ru.is>
 
-// Copyright (C) 2003, 2005 Free Software Foundation, Inc.
+// Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -56,14 +56,15 @@
       FILE* file = fopen(name, "w");
       fputs("Whatever\n", file);
       fflush(file);
-      s1.signal ();
-      s2.wait ();
+      s1.signal();
+      s2.wait();
       fclose(file);
+      s1.signal();
       exit(0);
     }
-  
+
   freopen(name, "r", stdin);
-  s1.wait ();
+  s1.wait();
 
   wint_t c1 = fgetwc(stdin);
   VERIFY( c1 != WEOF );
@@ -81,7 +82,8 @@
   wint_t c5 = wcin.rdbuf()->sgetc();
   VERIFY( c5 != WEOF );
   VERIFY( c5 == c4 );
-  s2.signal ();
+  s2.signal();
+  s1.wait(); 
 }
 
 int main()
Index: testsuite/27_io/objects/char/9661-1.cc
===================================================================
--- testsuite/27_io/objects/char/9661-1.cc	(revision 111977)
+++ testsuite/27_io/objects/char/9661-1.cc	(working copy)
@@ -3,7 +3,7 @@
 
 // 2003-04-30  Petur Runolfsson <peturr02@ru.is>
 
-// Copyright (C) 2003, 2005 Free Software Foundation, Inc.
+// Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -57,14 +57,15 @@
       VERIFY (file != NULL);
       fputs("Whatever\n", file);
       fflush(file);
-      s1.signal ();
-      s2.wait ();
+      s1.signal();
+      s2.wait();
       fclose(file);
+      s1.signal();
       exit(0);
     }
-  
+
   freopen(name, "r", stdin);
-  s1.wait ();
+  s1.wait();
 
   int c1 = fgetc(stdin);
   VERIFY( c1 != EOF );
@@ -82,7 +83,8 @@
   int c5 = cin.rdbuf()->sgetc();
   VERIFY( c5 != EOF );
   VERIFY( c5 == c4 );
-  s2.signal ();
+  s2.signal();
+  s1.wait();
 }
 
 int main()
Index: testsuite/27_io/basic_filebuf/underflow/char/10097.cc
===================================================================
--- testsuite/27_io/basic_filebuf/underflow/char/10097.cc	(revision 111977)
+++ testsuite/27_io/basic_filebuf/underflow/char/10097.cc	(working copy)
@@ -3,7 +3,8 @@
 
 // 2001-05-21 Benjamin Kosnik  <bkoz@redhat.com>
 
-// Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006
+// Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -61,7 +62,7 @@
       VERIFY( false );
     }
   
-  semaphore s1;
+  semaphore s1, s2;
   int fval = fork();
   if (fval == -1)
     {
@@ -72,11 +73,12 @@
     {
       filebuf fbout;
       fbout.open(name, ios_base::in|ios_base::out);
-      VERIFY ( fbout.is_open() );
+      VERIFY( fbout.is_open() );
       fbout.sputn("0123456789", 10);
       fbout.pubsync();
-      s1.wait ();
+      s1.wait();
       fbout.close();
+      s2.signal();
       exit(0);
     }
 
@@ -97,7 +99,8 @@
     }
 
   fb.close();
-  s1.signal ();
+  s1.signal();
+  s2.wait();
 }
 
 int main() 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]