Re: [Valgrind-users] Helgrind doesn't handle bit field correctly

2013-03-25 Thread Will Deng
Without seeing the precise code that is creating the locks and accessing the variables, it is hard to be certain that it is in fact safe. Can you reduce it to a minimal sample? Are you using only POSIX pthread primitives, or properly describing the lock primitives you are using? If you can cr

Re: [Valgrind-users] Helgrind doesn't handle bit field correctly

2013-03-22 Thread David Chapman
On 3/22/2013 4:52 PM, you wrote: When threads are writing to bit fields, there are mutex locks. It's an existing condition and it worked well from many years. So I wonder if there is a way to get around the "false" errors from Helgrind? Thanks. Without seeing the precise code that is creat

Re: [Valgrind-users] Helgrind doesn't handle bit field correctly

2013-03-22 Thread David Faure
On Friday 22 March 2013 14:54:09 Will Deng wrote: > Hi, > > 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 > r

Re: [Valgrind-users] Helgrind doesn't handle bit field correctly

2013-03-22 Thread David Chapman
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_

Re: [Valgrind-users] Helgrind doesn't handle bit field correctly

2013-03-22 Thread John Reiser
> How about one thread writes, but the other thread only reads? Exactly one particular thread, whose identity never changes, can be a writer. Any other thread must never write to any portion of the enclosing addressable object. -- ---

Re: [Valgrind-users] Helgrind doesn't handle bit field correctly

2013-03-22 Thread Will Deng
You are right. How about one thread writes, but the other thread only reads? From: David Chapman [mailto:dcchap...@acm.org] Sent: Friday, March 22, 2013 3:46 PM To: Will Deng Cc: valgrind-users@lists.sourceforge.net Subject: Re: [Valgrind-users] Helgrind doesn't handle bit field correctly

Re: [Valgrind-users] Helgrind doesn't handle bit field correctly

2013-03-22 Thread David Chapman
On 3/22/2013 3:35 PM, Will Deng wrote: Even if two threads are writing to the same word, as long as thread 1 doesn't modify thread_2_data, it should be ok, right? Nope: the usual way for a processor to do this is to read the entire word, modify the appropriate bits, and then write the ent

Re: [Valgrind-users] Helgrind doesn't handle bit field correctly

2013-03-22 Thread Will Deng
users] Helgrind doesn't handle bit field correctly 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

Re: [Valgrind-users] Helgrind doesn't handle bit field correctly

2013-03-22 Thread John Reiser
> 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_

[Valgrind-users] Helgrind doesn't handle bit field correctly

2013-03-22 Thread Will Deng
Hi, 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 conditi