Category : race-condition

Recently Eric Niebler had a tweet about volatile and thread safety and somebody replied with the link to following code from Intel TBB. void Block::shareOrphaned(intptr_t binTag, unsigned index) { MALLOC_ASSERT( binTag, ASSERT_TEXT ); // unreferenced formal parameter warning tbb::detail::suppress_unused_warning(index); STAT_increment(getThreadId(), index, freeBlockPublic); markOrphaned(); if ((intptr_t)nextPrivatizable==binTag) { // First check passed: the block is not in ..

Read more

I am working fixing on some coverity issues and i am confused about how to solve toctou for stat a directory and make a directory. //////////////////////////////////// // Make sure storage dir exists. If // not, create it. if( stat( dir, &statBuff ) != -1 ) { if( S_ISDIR( statBuff.st_mode ) ) { if( (dirPtr = ..

Read more

The following excerpt is taken from the website https://lwn.net/Articles/262464/ and it is dealing with read-inconsistencies of shared data structures (for which there was the RCU created): p = gp; if (p != NULL) { do_something_with(p->a, p->b, p->c); } Although this code fragment might well seem immune to misordering, unfortunately, the DEC Alpha CPU [PDF] and ..

Read more

Let’s say the interface function which performs the entire operation looks like this: result_t c_worker::minimize_somethings(input_t const& obj1, input_t const& obj2) const { … } I’m working with a functor, say, compute_cost which is the core evaluator of a cost-function of an optimization algorithm. This requires obj1 und obj2 in order to perform its activity. However, ..

Read more