[PATCH v2] gold: ensure file_counts_lock is initialized before using
Cary Coutant
ccoutant@gmail.com
Mon Nov 2 18:10:34 GMT 2020
> Since upgrading to binutils 2.35 I've been experiencing random memory
> corruption related crashes with ld.gold --threads. It's caused by
> multiple threads concurrently pushing elements onto the shared
> std::vector in File_read::record_file_read(). This vector is supposed to
> be protected by file_counts_lock, but that is initialized lazily and
> might be NULL when File_read::open() is called, in which case
> Hold_optional_lock silently skips locking it.
>
> Fix by calling the initialize() method before attempting to acquire the
> lock, the same as other places that use file_counts_lock.
>
> PR 26827
> * fileread.cc (File_read::open): Ensure file_counts_lock is
> initialized.
> * testsuite/Makefile.am (check_PROGRAMS): Add a test that passes
> -Wl,--threads.
> ---
> Add a test (basic_threads_test) that crashes with current gold.
> Link to PR.
Sorry, I should have approved this updated patch instead.
-cary
More information about the Binutils
mailing list