forked from Imagelibrary/binutils-gdb
Fix race in background index-cache writing
Tom de Vries pointed out a bug in the index-cache background writer -- sometimes it will fail. He also noted that it fails when the number of worker threads is set to zero. These turn out to be the same problem -- the cache can't be written to until the per-BFD's "index_table" member is set. This patch avoids the race by rearranging the code slightly, to ensure the cache cannot possibly be written before the member is set. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30261
This commit is contained in:
@@ -366,7 +366,7 @@ public:
|
||||
object. */
|
||||
using vec_type = std::vector<std::unique_ptr<cooked_index_shard>>;
|
||||
|
||||
cooked_index (vec_type &&vec, dwarf2_per_bfd *per_bfd);
|
||||
explicit cooked_index (vec_type &&vec);
|
||||
~cooked_index () override;
|
||||
DISABLE_COPY_AND_ASSIGN (cooked_index);
|
||||
|
||||
@@ -429,6 +429,9 @@ public:
|
||||
m_write_future.wait ();
|
||||
}
|
||||
|
||||
/* Start writing to the index cache, if the user asked for this. */
|
||||
void start_writing_index (dwarf2_per_bfd *per_bfd);
|
||||
|
||||
private:
|
||||
|
||||
/* Maybe write the index to the index cache. */
|
||||
|
||||
Reference in New Issue
Block a user