On Wednesday 20 August 2014 01:08:41 Philippe Waroquiers wrote:
> On Tue, 2014-08-19 at 22:29 +0200, Philippe Waroquiers wrote:
> > > It doesn't use __thread anywhere, but rather lets gcc take care of
> > > ensuring
> > > thread-safety on static objects (like C++11 mandates, but it has been
> > > doing so for a long time already).
> > 
> > Quickly re-reading the mail, this is not related.
> > I see that drd has some interceptions that does annotate
> > these like a mutex lock/unlock (see drd/drd_libstdcxx_intercepts.c)
> > and has a test which looks like your problem in
> > drd/tests/local_static.cpp
> > 
> > I think a similar code is (trivially) doable for helgrind,
> > inside helgrind/hg_intercepts.c
> 
> Just tried to do this trivial code.
> But I still had (what looks like) false positive.
> Probably explanation is that these drd intercepts are not working (yet),
> as documented in log for revision 14013:
>   r14013 | bart | 2014-06-09 11:00:42 +0200 (Mon, 09 Jun 2014) | 1 line
> 
>   drd/tests/local_static: Disable because g++ does not yet allow proper
>   interception of initialization of local static variables
> 
> I have no idea what problem/difficulty was encountered.
> 
> What is exactly the semantic of a threadsafe static ?
> I understand it is initialised only once, and that such 'init once'
> is guaranteed thanks to __cxa_guard_acquire/__cxa_guard_release.
> However, what is __cxa_guard_abort used for ?
> 
> Once the object is initialised, I guess it must be either used
> read-only by all threads, or have a classical way to be protected
> (e.g. via a mutex).

Not sure if that helps you, but here's an excerpt from the current version of 
the C++11 standard draf, which you can obtain free-of-charge on isocpp.org 
[1].From §6.7.4 (Declaration statement):

If control enters the declaration concurrently while the variable is being 
initialized, the concurrent execution shall wait for completion of the 
initialization.

The implementation must not introduce any deadlock around execution of the 
initializer.

See also [2] and search for "Using a C++11 Static Initializer".

[1]: https://isocpp.org/std/the-standard
[2]: http://preshing.com/20130930/double-checked-locking-is-fixed-in-cpp11/

HTH

-- 
Milian Wolff
m...@milianw.de
http://milianw.de

------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to