PATCH: fix locking bug on FileRead::Open()

Craig Silverstein csilvers@google.com
Thu Aug 21 00:33:00 GMT 2008


I just committed this patch, which affects commands like these:

   ./ld --version-script=/no/such/file
   ./ld -b binary /no/such/file

Before, they would trigger an assert, because even though the file
wasn't found, it was acquiring a lock that never got released.  The
patch below fixes that.

Approved offline by Ian Taylor.

craig

--cut here--

2008-08-20  Craig Silverstein  <csilvers@google.com>

	* fileread.cc (File_read::open): Do not lock the file unless it
	was successfully opened.

--- fileread.cc.~1.42.~	2008-08-19 21:45:39.000000000 -0700
+++ fileread.cc	2008-08-20 16:14:34.472018000 -0700
@@ -121,9 +121,9 @@
       this->size_ = s.st_size;
       gold_debug(DEBUG_FILES, "Attempt to open %s succeeded",
                  this->name_.c_str());
-    }
 
-  this->token_.add_writer(task);
+      this->token_.add_writer(task);
+    }
 
   return this->descriptor_ >= 0;
 }



More information about the Binutils mailing list