* archive.cc (Lib_group::add_symbols): Lock object before deleting its
authorCary Coutant <ccoutant@google.com>
Mon, 23 Aug 2010 20:28:24 +0000 (20:28 +0000)
committerCary Coutant <ccoutant@google.com>
Mon, 23 Aug 2010 20:28:24 +0000 (20:28 +0000)
symbols data.
(Lib_group::include_member): Unlock object after deleting its
symbols data.
* testsuite/start_lib_test_3.c: Remove all global symbols to trigger
the bug fixed here.

gold/ChangeLog
gold/archive.cc
gold/testsuite/start_lib_test_3.c

index beea4a3c90766aa539fd36940c046b145b1c1904..e2792b2dac2affa5fa6d4b42e09b18ef8746e571 100644 (file)
@@ -1,3 +1,12 @@
+2010-08-23  Cary Coutant  <ccoutant@google.com>
+
+       * archive.cc (Lib_group::add_symbols): Lock object before deleting its
+       symbols data.
+       (Lib_group::include_member): Unlock object after deleting its
+       symbols data.
+       * testsuite/start_lib_test_3.c: Remove all global symbols to trigger
+       the bug fixed here.
+
 2010-08-19  Neil Vachharajani  <nvachhar@google.com>
            Cary Coutant  <ccoutant@google.com>
 
index 68a674ddfe8706aac845b6d9638866615e3ab006..dade0430de2eab1b85bead32b126828e2360d1d6 100644 (file)
@@ -1057,7 +1057,14 @@ Lib_group::add_symbols(Symbol_table* symtab, Layout* layout,
           else
             {
               if (member.sd_ != NULL)
-                delete member.sd_;
+               {
+                 // The file must be locked in order to destroy the views
+                 // associated with it.
+                 gold_assert(obj != NULL);
+                 obj->lock(this->task_);
+                 delete member.sd_;
+                 obj->unlock(this->task_);
+               }
             }
 
          this->members_[i] = this->members_.back();
@@ -1096,10 +1103,10 @@ Lib_group::include_member(Symbol_table* symtab, Layout* layout,
        layout->incremental_inputs()->report_object(obj, NULL);
       obj->layout(symtab, layout, sd);
       obj->add_symbols(symtab, sd, layout);
-      // Unlock the file for the next task.
-      obj->unlock(this->task_);
     }
   delete sd;
+  // Unlock the file for the next task.
+  obj->unlock(this->task_);
 }
 
 // Print statistical information to stderr.  This is used for --stats.
index 555eea12bf21285e45ab7e1380b08cae2334314b..86444e00995e63d22e3ef6e0a699dcb312094a52 100644 (file)
@@ -22,9 +22,4 @@
 
    This is a test of the --start-lib and --end-lib options.  */
 
-extern void t3 (void);
-
-void
-t3 (void)
-{
-}
+static char t3[] = "t3";