|
From: Dave O. <dav...@gm...> - 2014-06-06 07:33:43
|
Hi Bart,
Thank you for trying to help.
However, the code you posted, and the included comments, match pretty much
what I already did.
So, to rehash:
1. I use:
- RedHad Linux 2.6
- g++ 4.7.2
- Valgrind 3.7.0
2. I copy-paste the code from your message to main.cc, the one difference
being drd.h's path:
#include <valgrind/drd.h>
#define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(addr) \
ANNOTATE_HAPPENS_BEFORE(addr)
#define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(addr) \
ANNOTATE_HAPPENS_AFTER(addr)
#define _GLIBCXX_EXTERN_TEMPLATE -1
#include <iostream>
#include <thread>
int main(int argc, char** argv)
{
std::thread t( []() { } );
t.join();
std::cerr << "Done.\n";
return 0;
}
3. I build the program:
$ g++ -std=c++11 -Wall -Wextra -pthread main.cc
main.cc:11:5: warning: unused parameter 'argc' [-Wunused-parameter]
main.cc:11:5: warning: unused parameter 'argv' [-Wunused-parameter]
4. I run the program:
$ ./a.out
Done.
5. I run the program with DRD:
$ valgrind --tool=drd ./a.out
=> I get a bunch of false positives - "Possible data race during write of
size 8", etc. - see my post at
http://stackoverflow.com/questions/24060626/cannot-get-helgrind-drd-work-with-c11-thread
What's the problem?
-- dave
On Fri, Jun 6, 2014 at 10:01 AM, Bart Van Assche <bva...@ac...> wrote:
> On 06/06/14 07:27, Dave Ohlsson wrote:
> > I posted yesterday a question to stackoverflow regarding problems I am
> > having with Helgrind/DRD and C++11 thread:
> >
> >
> http://stackoverflow.com/questions/24060626/cannot-get-helgrind-drd-work-with-c11-thread
> >
> > but got no answer.
>
> I think the source code comments in the test program below answer your
> question.
>
> Bart.
>
> $ cat drd/tests/std_thread.cpp
> // Test whether no race conditions are reported on std::thread. Note: since
> // the implementation of std::thread uses the shared pointer
> implementation,
> // that implementation has to be annotated in order to avoid false
> positives.
> // See also http://gcc.gnu.org/onlinedocs/libstdc++/manual/debug.html for
> more
> // information.
>
> #include "../../drd/drd.h"
> #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(addr) \
> ANNOTATE_HAPPENS_BEFORE(addr)
> #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(addr) \
> ANNOTATE_HAPPENS_AFTER(addr)
> #define _GLIBCXX_EXTERN_TEMPLATE -1
>
> #include <iostream>
> #include <thread>
>
> int main(int argc, char** argv)
> {
> std::thread t( []() { } );
> t.join();
> std::cerr << "Done.\n";
> return 0;
> }
>
>
|