[RFC][PATCH] fix Read_symbols datarace

Evgeniy Dushistov dushistov@mail.ru
Wed Nov 5 23:58:00 GMT 2014


On Wed, Nov 05, 2014 at 02:53:47PM -0800, Cary Coutant wrote:
> > After update to gcc 4.9.2, link of my project failed,
> > because of ld.gold crash.
> > I reproduce this problem:
> > https://sourceware.org/bugzilla/show_bug.cgi?id=17538
> > ...
> > Attached patch fix problem for me.
> > Comments?
> 
> Thanks for finding this! A couple of minor comments, but it looks good...
> 
> Please write a ChangeLog entry.
> 
> +      this_blocker_(NULL), extra_search_path_(), lock_(NULL),
> initialize_lock_(&lock_)
> 
> Line too long; please wrap.
> 
> +  Lock *lock_;
> 
> For C++ code, the "*" goes with the type: "Lock* lock_;".
> 

I fixed coding styles issues, and add changelog entry.
See attached patch.

> Do you have commit access?
> 
No, I saw the gold code the first time in my life,
so no, I have no commit access.


-- 
/Evgeniy
-------------- next part --------------
diff --git a/gold/ChangeLog b/gold/ChangeLog
index 4901215..3ab5b80 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,6 @@
+2014-11-06  Evgeniy Dushistov<dushistov@mail.ru>
+	* gold/plugin.cc: use lock to searialize calls of Plugin_manager::claim_file
+	* gold/plugin.h: add lock definition
 2014-10-29  Han Shen  <shenhan@google.com>
 	    Jing Yu   <jingyu@google.com>
 
diff --git a/gold/plugin.cc b/gold/plugin.cc
index 0339d42..4b0f3cf 100644
--- a/gold/plugin.cc
+++ b/gold/plugin.cc
@@ -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;
 
diff --git a/gold/plugin.h b/gold/plugin.h
index 9ef2812..f27f98d 100644
--- a/gold/plugin.h
+++ b/gold/plugin.h
@@ -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_;
 };
 
 


More information about the Binutils mailing list