$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [Boost-users] Thread changes from Boost 1.38 to 1.45
From: Ven Tadipatri (ven.tadipatri_at_[hidden])
Date: 2011-02-01 11:04:18
Our application is quite large and it's hard to determine what exactly 
is triggering the error. But the exception itself happens in the wait 
method in condition_variable_any.
Actually, I do seem some calls to timed_wait so I think I might be 
running into similar errors. Could you point me to how others have 
resolved the problem?
The error message that's displayed is:
terminate called after throwing an instance of 
'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::lock_error> 
 >'
   what():  boost::lock_error
And I've confirmed that the error only exists when using Boost 1.45, not 
Boost 1.38.
Here is what the wait method looks like in Boost 1.45:
template<typename lock_type>
         void wait(lock_type& m)
         {
             int res=0;
             {
                 thread_cv_detail::lock_on_exit<lock_type> guard;
                 detail::interruption_checker 
check_for_interruption(&internal_mutex,&cond);
                 guard.activate(m);
                 res=pthread_cond_wait(&cond,&internal_mutex);
                 this_thread::interruption_point();
                 //error occurs here, when lock_on_exit's destructor is 
called
             }
             if(res)
             {
                 boost::throw_exception(condition_error());
             }
         }
This is the same method in Boost 1.38:
         template<typename lock_type>
         void wait(lock_type& m)
         {
             int res=0;
             {
                 detail::interruption_checker check_for_interruption(&cond);
                 {
                     boost::pthread::pthread_mutex_scoped_lock 
internal_lock(&internal_mutex);
                     m.unlock();
                     res=pthread_cond_wait(&cond,&internal_mutex);
                    //no equivalent lock_on_exit.
                 }
                 m.lock();
             }
             if(res)
             {
                 throw condition_error();
             }
         }
Thanks,
Ven
On 02/01/2011 03:30 AM, Anthony Williams wrote:
> Ven Tadipatri<ven.tadipatri_at_[hidden]>  writes:
>
>> Hi,
>>     We upgraded our project from using Boost 1.38 to Boost 1.45 but now
>> seem to be having some thread issues. The error doesn't happen for
>> every run, but occasionally the wait method in condition_variable_any
>> fails. At other times the program seems to run into an infinite loop,
>> presumably waiting for a lock that's never released. I looked at the
>> changes in
>> http://www.boost.org/doc/libs/1_45_0/doc/html/thread/changes.html but
>> don't see what could be causing the error to occur only after
>> upgrading to Boost 1.45.
>>     Has anyone else experienced their code breaking when upgrading to
>> the latest version of Boost?
> This seems similar to the problems people have experience with
> boost::this_thread::sleep (which I cannot reproduce), which relies on
> condition_variable::timed_wait.
>
> I don't think anything significant has changed in that area, so it
> surprises me that you are experiencing problems only after upgrading.
>
> Can you give more information about the problem? A small sample
> application that demonstrates it would be nice.
>
> Anthony