|
[
Permlink
| « Hide
]
Martin Sebor added a comment - 19/Jun/07 01:10 AM
Attached HTML output from the tool.
I think these are benign, at least on x86 and x86_64, since the code has been there for eons and the string thread safety tests have been passing, but I'll leave it open so that when we have a bit more time in the 4.2.1 release cycle we can do a better analysis. At the very least we can silence the ITC errors as false positives. Bumped down Priority to Minor and scheduled for 4.2.1.
According to this
The type of _C_ref is int, which is only 32-bits on a LLP64 systems. I believe that this is okay on EMT64/AMD64 systems because they are actually 32-bit architectures with 64-bit extensions, but I'm not absolutely sure. Need to find out. According to this
That same page also says this
Assuming that the first two quotes are accurate, and the _C_refs member is properly aligned and of the appropriate size on all platforms, we should be safe. Even if all of that works out, I don't feel good about it. My initial inclination is to say that we need something to guard the read of _C_refs. We need to make sure that all writes are flushed before we read the current value. I was originally considering something like atomic_add(_C_refs, 0), assuming it would ensure that the returned value was consistent, but the last quote leaves me a little unsure if that is sufficient. There are two potential problems here: word tearing (accessing parts of the same word non-atomically), and a data race between two conflicting accesses to the same word. I agree that word-tearing is a non-issue on all our platforms (some implementations of the Alpha processor had this property – see this article
In any case, if we're comfortable with limiting this issue to the Intel Thread Checker errors on i386 (or x86_64), it would be safe to ignore such architectures. And if we're also comfortable with treating the ITC errors as benign on i86 we can simply suppress them. I can think of two ways of doing it without seriously impacting the performance of the code:
IMO, the second option is the more robust of the two but I'm not sure how feasible it is to implement it. Well, I haven't found any way suppress warnings from the thread checker utility using pragmas, so I think option 1 is out.
The only way that I've seen that seems workable is to use the Intel Thread Tools library and make the necessary calls to notify the thread checker that what we are doing is safe. I'm pretty sure this is what you are saying with option 2. We can detect at compile time if the user is building reentrant code with -tcheck option on the Intel compiler. If this is the case we could enable the thread checker code. One problem with this is that we also need the path to the include file libittnotify.h, as well as the link line to support linking to libittnotify.so and libassuret40.so. If we are going to be doing thread checker runs with any frequency, then we could just gather up the thread checker output of all the tests/examples, and then run that output through a filter to hide [or de-emphasize] the ones that we don't care about, and then generate some fancy html output like the rest of the build infrastructure does. Note that we don't have to limit this to only Intel C++ builds with the -tcheck flag. We could allow the user to define a macro to enable this thread checker code also.
Well, as I pointed out above, the only way I see to deal with this is to use the thread checker notify library to tell the thread checker that things are okay. If this is the route that we decide to go, then the attached file include/rw/_tcheck.h may be useful.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||