> 
> I don't understand why static variables can cause any safety issue in
> multi-thread programs.
> For any process, gcov_dump will be called only once and there will be
> one instance of globals.

(v)fork, failing exec and other cases can lead to gcov_flush being called
several times  and that calls gcov_exit that uses the global state.

I believe that a simple program containing two threads that both are executing
execve of non-existing file will trigger concurent writes on systems not
having __gthread_mutex_lock  that seems to be in place to prevent it.

I wonder if we should move move locking into gcov_exit itself?
Is there somethign that will promise us that paralellel streaming invoked by
other thread at the failing execve is not going to end up in parallel with
gcov_exit called via atexit handler?

In any case for sanity of setups without gthread support, I think we need to
keep eye on not doing something evil in this case - like writting into random
file names or corrupting memory/files.

> 2014-01-08  Rong Xu  <x...@google.com>
> 
>       * libgcc/libgcov-driver.c (this_prg): make it local to save
>         bss space.
>       (gcov_exit_compute_summary): Ditto.
>       (gcov_exit_merge_gcda): Ditto.
>       (gcov_exit_merge_summary): Ditto.
>       (gcov_exit_dump_gcov): Ditto.

This is OK, thanks!
Honza

Reply via email to