Fix race condition when using --threads with linker plugins.
authorEvgeniy Dushistov <dushistov@mail.ru>
Sat, 8 Nov 2014 00:12:58 +0000 (16:12 -0800)
committerCary Coutant <ccoutant@google.com>
Sat, 8 Nov 2014 00:12:58 +0000 (16:12 -0800)
2014-11-06  Evgeniy Dushistov  <dushistov@mail.ru>

gold/
* plugin.cc: use lock to searialize calls of Plugin_manager::claim_file
* plugin.h: add lock definition

gold/ChangeLog
gold/plugin.cc
gold/plugin.h

index 4901215b1a55b9f7fe69cae7fb3989e27a41316a..5c719fc6348697febc590f3963bceb8b5e90d6de 100644 (file)
@@ -1,3 +1,8 @@
+2014-11-06  Evgeniy Dushistov  <dushistov@mail.ru>
+
+       * plugin.cc: use lock to searialize calls of Plugin_manager::claim_file
+       * plugin.h: add lock definition
+
 2014-10-29  Han Shen  <shenhan@google.com>
            Jing Yu   <jingyu@google.com>
 
index 0339d4289d4c6ecb87d7c0cf9a245a37bfe3ef95..4b0f3cfb01c9c59512910004b7f09edfcf8ab83c 100644 (file)
@@ -427,6 +427,7 @@ Plugin_manager::~Plugin_manager()
        ++obj)
     delete *obj;
   this->objects_.clear();
+  delete this->lock_;
 }
 
 // Load all plugin libraries.
@@ -447,6 +448,10 @@ Pluginobj*
 Plugin_manager::claim_file(Input_file* input_file, off_t offset,
                            off_t filesize, Object* elf_object)
 {
+  bool lock_initialized = this->initialize_lock_.initialize();
+
+  gold_assert(lock_initialized);
+  Hold_lock hl(*this->lock_);
   if (this->in_replacement_phase_)
     return NULL;
 
index 9ef2812909284cc90b8894d8645647f71d524be0..f27f98dbdd2eeba0367cf696778ae403e1542e5f 100644 (file)
@@ -134,7 +134,8 @@ class Plugin_manager
       in_claim_file_handler_(false),
       options_(options), workqueue_(NULL), task_(NULL), input_objects_(NULL),
       symtab_(NULL), layout_(NULL), dirpath_(NULL), mapfile_(NULL),
-      this_blocker_(NULL), extra_search_path_()
+      this_blocker_(NULL), extra_search_path_(), lock_(NULL),
+      initialize_lock_(&lock_)
   { this->current_ = plugins_.end(); }
 
   ~Plugin_manager();
@@ -376,6 +377,8 @@ class Plugin_manager
   // An extra directory to seach for the libraries passed by
   // add_input_library.
   std::string extra_search_path_;
+  Lock* lock_;
+  Initialize_lock initialize_lock_;
 };
 
 
This page took 0.032662 seconds and 4 git commands to generate.