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]

[Patch] Fix pthread7-rope.cc


Hi,

today I noticed something really weird: pthread7-rope.cc was failing
also when configured to run /single/ threaded! Hummm...

Turns out the testcase is partially wrong ;)

We had this:

const char* data2;

 {
   __gnu_cxx::crope foo2;
   foo2 += "bar2";
   foo2 += "baz2";
   foo2 += "bongle2";
   data2 = foo2.c_str();
   VERIFY( !std::strcmp (data2, "bar2baz2bongle2") );
 }

 ...
 ...
 ...

VERIFY( std::strcmp (data2, "bar2baz2bongle2") );


Therefore, we were enforcing that the operations in the middle actually trashed the (deallocated) memory pointed by data2.

Of course this is not the kind of thing you can reliably predict: a
different allocator leads, by chance, to the memory not being trashed.

Tomorrow morning will commit the below, which brings us to a clean
testsuite for mt_allocator on x86/x86_64/ia64.

Paolo.

//////////////
2004-03-29  Paolo Carlini  <pcarlini@suse.de>

	* testsuite/thread/pthread7-rope.cc: Fix, unpredictably, depending
	on allocator behavior, the memory pointed by data2 may well be not
	trashed.
diff -urN libstdc++-v3-orig/testsuite/thread/pthread7-rope.cc libstdc++-v3/testsuite/thread/pthread7-rope.cc
--- libstdc++-v3-orig/testsuite/thread/pthread7-rope.cc	2004-03-05 00:29:44.000000000 +0100
+++ libstdc++-v3/testsuite/thread/pthread7-rope.cc	2004-03-28 10:43:04.000000000 +0200
@@ -34,6 +34,7 @@
 const int max_thread_count = 4;
 const int max_loop_count = 10000;
 
+__gnu_cxx::crope foo2;
 __gnu_cxx::crope foo4;
 
 void* thread_main(void *) 
@@ -81,7 +82,6 @@
 
   const char* data2;
   {
-    __gnu_cxx::crope foo2;
     foo2 += "bar2";
     foo2 += "baz2";
     foo2 += "bongle2";
@@ -108,7 +108,8 @@
     }
 
   // Nothing says the data will be trashed at this point...
-  VERIFY( std::strcmp (data2, "bar2baz2bongle2") );
+  VERIFY( !std::strcmp (data, "barbazbongle") );
+  VERIFY( !std::strcmp (data2, "bar2baz2bongle2") );
 
   return 0;
 }

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