|
Boost Users : |
Subject: Re: [Boost-users] shared_lock( ) causes Segmentation Fault in CentOS 5.5 x64?
From: Zap (zippo.fire_at_[hidden])
Date: 2011-03-16 00:05:51
Howard Hinnant <howard.hinnant <at> gmail.com> writes:
>
> On Mar 14, 2011, at 11:39 PM, DesertFish wrote:
>
> It looks like you are locking your structure in "read mode" and then writing
to it:
>
> > boost::shared_lock<boost::shared_mutex> lock(rwMutex);
> > for(boost::unordered_set<int>::iterator it=tablePush[pair<string, string>
> > (type, code)].begin();it!=tablePush[pair<string, string>(type, code)].end
> > ();it++){
> > flag=true;
> > des->push_back(*it);
> > }
>
> If you want to lock it in write mode do this:
>
> boost::unique_lock<boost::shared_mutex> lock(rwMutex);
>
> -Howard
>
Hi Howard,
I just tested a simple case,
which just lock the read lock and print out the result
of tablePush.size(), like this:
bool getFD(list<int> *des, char *type, char *code){
bool flag=false;
boost::shared_lock<boost::shared_mutex> lock(rwMutex);
cout<<tablePush[pair<string, string>(type, code)].size()<<endl;
return flag;
}
but it still happens Segmentation Fault...
could anyone know what's the problem is?
Thank you
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net