On Jan 10, 2008 8:48 PM, Gennadiy Rozental <rogeeff@gmail.com> wrote:
Ovanes Markarian <om_boost <at> keywallet.com> writes:
> struct thread_safety_test
> {
>     static void thread_function(boost::barrier& b)
>     {
>         b.wait();

Can't comment in these. I never used this class.

|         boost::mutex::scoped_lock lock(m);
|         BOOST_CHECK_EQUAL(1,0);
|     }
|
|     void test_multiple_assertion_faults()
|     {
|         boost::thread_group tg;
|         boost::barrier b(100);
|
|         for(size_t i=0; i<100; ++i)
|         {
|             tg.create_thread (boost::bind(thread_function, ref(b)));
|         }
|     }
| };
| But unfortunately this does not work. May be I miss smth. here.

>I am not an expert in MT, but what exactly is the problem?
>
>Do you run is from inside the test case?


Yes. The class specified is passed to the BOOST_CLASS_TEST_CASE( multiple_assertion_faults, thread_safety_test)

The idea of my code is:
Create 100 threads and wait until all of them are created. (barrier is used for that).

After all threads were created lock the mutex and produce the assertion fault. In MSVC 7.1 this code crashes after the second call to BOOST_CHECK_EQUAL.


I thought you would be aware of this issue.


Many thanks for your help!
Ovanes