|
From: Bart V. A. <bar...@gm...> - 2009-05-20 12:05:36
|
On Wed, May 20, 2009 at 1:13 PM, Julian Seward <js...@ac...> wrote: > On Wednesday 20 May 2009, Nicholas Nethercote wrote: >> On Wed, May 20, 2009 at 6:22 PM, Julian Seward <js...@ac...> wrote: >> > Independently of your commit .. does this work reliably? It looks >> > distinctly un-thread-safe to me :-) >> > >> > if (init_done) >> > return; >> > init_done = 1; >> > // actually do said initialisation >> >> Probably not, but Valgrind is single-threaded and I expect there are a >> lot of other un-thread-safe things like this...? > > But this is a bit different .. it runs on the VCPU, not the real one, > hence is not as a whole protected by the standard BigLock scheme. > iiuc .. If the assignment to the variable init_done would be triggering a race condition, both DRD and Helgrind would report this race. By the way, although the init() function in coregrind/m_replacemalloc/vg_replace_malloc.c has been declared __attribute__((constructor)), it is not safe to remove the variable init_done. This is because it is possible that malloc() and hence init() gets called before shared library initialization finished. Bart. |