Follow-up Comment #10, sr #130984 (project xrootd):
I think I found the problem.
I first thought that there is a race condition between threads, but Mutexes
seems to be used everywhere in a consistent way. The problem is in erasing
elements of std::map while looping through its elements in
XrdXrootd/XrdXrootdStats.cc:87
for ( it=clients.begin() ; it != clients.end(); it++ )
{
len += sprintf(cl_buff, client_info, (*it).first, (*it).second,
(*it).first);
clients.erase((*it).first);
strcat(buff,cl_buff);
memset(cl_buff,0,sizeof(cl_buff));
}
The only things gets that invalidated after std::map.erase() call are the
iterators to the erased elements. In the snippet above, the code will use the
invalidated iterator while changing to the next iteration (first line).
This should fix the issue (haven't tried yet):
--- XrdXrootd/XrdXrootdStats.cc 2012-08-08 23:11:20.000000000 +0200
+++ XrdXrootd/XrdXrootdStats.cc.fixed 2012-08-08 23:13:27.000000000 +0200
@@ -84,10 +84,10 @@
LoginAT, AuthBad, LoginAU, LoginUA);
client_mutex.Lock();
- for ( it=clients.begin() ; it != clients.end(); it++ )
+ for ( it=clients.begin() ; it != clients.end(); )
{
len += sprintf(cl_buff, client_info, (*it).first, (*it).second,
(*it).first);
- clients.erase((*it).first);
+ clients.erase(it++);
strcat(buff,cl_buff);
memset(cl_buff,0,sizeof(cl_buff));
}
Jiri Horky
_______________________________________________________
Reply to this item at:
<http://savannah.cern.ch/support/?130984>
_______________________________________________
Message sent via/by LCG Savannah
http://savannah.cern.ch/
########################################################################
Use REPLY-ALL to reply to list
To unsubscribe from the XROOTD-DEV list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=XROOTD-DEV&A=1
|