|
From: Bart V. A. <bar...@gm...> - 2009-05-20 08:32:03
|
On Wed, May 20, 2009 at 10:22 AM, Julian Seward <js...@ac...> wrote: [ ... ] (commenting on coregrind/m_replacemalloc/vg_replace_malloc.c) [ ... ] > 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 Every program I know of calls malloc() at least once before calling pthread_create(). So init_done gets initialized before any thread is created, and is only read when multiple threads are active simultaneously. Such an access pattern is safe. But it deserves at least a comment. Bart. |