[Cppcms-users] Possible data race in lru at cache_storage.cpp?
Brought to you by:
artyom-beilis
From: Vinicius P. <ds...@ha...> - 2015-04-09 15:10:13
|
Hi! I was testing my app with valgrind/helgrind and found some possible data race in cache_storage.cpp, i'm using version 1.0.5, and the code from lines 259-264 locks the lru_mutex fine, but later on in lines 374-375 there is some write to lru without a mutex to lock, there is a lock on access_lock but none in lru_mutex. Helgrind detected this as a possible data race, after i change the lines 374-375, following is a diff to it: --- cache_storage.cpp 2015-04-09 12:35:57.410064598 -0300 +++ cache_storage.cpp.fixed 2015-04-09 12:36:08.516731747 -0300 @@ -371,8 +371,11 @@ cont.generation=*gen; else cont.generation=generation++; - lru.push_front(main); - cont.lru=lru.begin(); + { + lock_guard lock(*lru_mutex); + lru.push_front(main); + cont.lru=lru.begin(); + } cont.timeout=timeout.insert(std::pair<time_t,pointer>(timeout_in,main)); if(triggers_in.find(key)==triggers_in.end()){ cont.triggers.push_back(triggers.insert(std::pair<string_type,pointer>(int_key,main) Is this valid or just some false positive and I overreact it? Well, hope it helps in anyway, helgrind shows a lot of problems in mysql library and in shared_ptr/shared_count usage that I really think are falses but if needed can post them also. By the way, in just a few hours i found at least 3 bugs in my own code with valgrind tools, got to know it via CppCMS site, recommend to anyone check it. Thanks for your time! |