On 3/22/2013 2:54 PM, Will Deng wrote:

In our application, we use bit fields a lot. For example:

class data {

unsigned int the_thread_1_data:1;

unsigned int the_thread_2_data:3;

...

};

When one thread is writing to the_thread_1_data, and another thread is reading or writing to the_thread_2_data, helgrind will flag racing condition. Is this a known issue in helgrind? Is there a way to get around this? I believe the operation is multithread safe.


Not safe. Bit fields are generally packed within the same word in memory, so you now have two threads trying to write the same word without a mutex.

Try an experiment: remove the field widths, so that each integer will be in a separate memory word. Helgrind should no longer report an error.

--
    David Chapman      [email protected]
    Chapman Consulting -- San Jose, CA
    Software Development Done Right.
    www.chapman-consulting-sj.com

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to