|
From: Sahni, J. <jit...@cr...> - 2007-12-17 22:10:46
|
I guess I am not following this ( as I am very new to helgrind and valgrind ) . I am using ACE based Queues and Tasks (http://www.cs.wustl.edu/~schmidt/ACE-overview.html <http://www.cs.wustl.edu/~schmidt/ACE-overview.html> ) and ACE already has Queue protection locks for multithread implementation ( over pthred for Linux and Windows API based threads for windows OS) . Are you suggesting I need to change ACE Queue put and get calls ? or do I need to change something in helgrind source code ? I read the helgrind documentation and I don't understand how helgrind will know when a message passed into the queue does or does NOT enter a race condition ? especially when all threads are created at start ... Thanks Jitan _____ From: Konstantin Serebryany [mailto:kon...@gm...] Sent: Monday, December 17, 2007 4:19 PM To: Sahni, Jitan Cc: val...@li...; val...@li... Subject: Re: [Valgrind-users] helgrind false alters in ACE Tasks ( Linux) I have the same issue with our own message queues. Helgrind does not support them out of the box but can be easily enhanced. I did it with the help of source code changes: void Put(T elem) { // put() method of your queue sem_t *uniq_sem = new sem_t; sem_init(uniq_sem); sem_post(uniq_sem); // now do the actual 'put' stuff, putting uniq_sem together with elem } T Get() { // get() method of your queue // do the actual 'get' stuff; get uniq_sem from queue together with elem sem_wait(uniq_sem); sem_destroy(uniq_sem); delete uniq_sem; return elem; } The good thing is that you don't really need to create a real semaphore -- just create a integer with unique value (I use atomic_increment of static var) and pass it to appropriate helgrind's user requests (see helgrind.h and hg_intercepts.c). The bad thing is that it might be challenging to achieve the same effect without source code changes. It is not enough to intercept the call to Put/Get routines -- you need to put something into the queue (at least, I did not find another way). --kcc On Dec 17, 2007 10:23 PM, Sahni, Jitan <jit...@cr... <mailto:jit...@cr...> > wrote: does helgrind work properly on ACE Tasks and Message Queues ? I am getting some helgrind race alerts when using ACE Tasks and Message Queues. Basically the parent and child thread are created at start of the program and then parent passes buffer of data to child thru ACE Message Queue . the waiting child picks the data , uses it and frees it . helgrind is alerting me on race condition on this model . Does helgrind work correctly on this model of multi threads ( tasks and Queues ) ? Also is there any way to print memory contents of the location printed in a race condition ? ============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html <http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html> ============================================================================== ------------------------------------------------------------------------- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace <http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace> _______________________________________________ Valgrind-users mailing list Val...@li... <mailto:Val...@li...> https://lists.sourceforge.net/lists/listinfo/valgrind-users <https://lists.sourceforge.net/lists/listinfo/valgrind-users> ============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html ============================================================================== |
|
From: Julian S. <js...@ac...> - 2007-12-18 11:35:55
|
> I have the same issue with our own message queues.
> Helgrind does not support them out of the box but can be easily enhanced.
>
> I did it with the help of source code changes:
>
> void Put(T elem) { // put() method of your queue
> sem_t *uniq_sem = new sem_t;
> sem_init(uniq_sem);
> sem_post(uniq_sem);
> // now do the actual 'put' stuff, putting uniq_sem together with elem
> }
>
> T Get() { // get() method of your queue
> // do the actual 'get' stuff; get uniq_sem from queue together with elem
> sem_wait(uniq_sem);
> sem_destroy(uniq_sem);
> delete uniq_sem;
> return elem;
> }
Yes. That is a good place to start; I also did some stuff like that.
Note that the initial value of the semaphore is zero. Also, use
semaphores and avoid condition variables -- see
http://www.valgrind.org/docs/manual/hg-manual.html#hg-manual.effective-use
point (3.) for reasons why.
> The good thing is that you don't really need to create a real semaphore --
> just create a integer with unique value (I use atomic_increment of static
> var) and pass it to appropriate helgrind's user requests (see helgrind.h
> and hg_intercepts.c).
Better to just be simple and use sem_* functions.
J
|