This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [GOLD][PATCH PROPOSAL] fix segmentation fault in the Task_function class


Viktor Kutuzov <vkutuzov@accesssoftek.com> writes:

> this patch proposal fixes a bug, which causes a segmentation fault in
> the Task_function class if a name for non-existed input object was
> passed and an additional command-line argument was used (except -o). I
> got this situation with the following command:
>
> arm-none-linux-gnueabi-ld missed-module.o -r -o module-out.o 
>
> ../install.binutils.gold.crossarm/bin/arm-none-linux-gnueabi-ld: 
>     error: cannot open missed-module.o: No such file or directory
> Segmentation fault

Thanks for pointing that out.  I fixed the problem in a slightly
different way, as follows.

Ian


2010-02-23  Viktor Kutuzov  <vkutuzov@accesssoftek.com>
	    Ian Lance Taylor  <iant@google.com>

	* gold.cc (queue_middle_tasks): If no input files were opened,
	exit.
	* workqueue.h (Task_function::Task_function): Assert that there is
	a blocker.


Index: gold.cc
===================================================================
RCS file: /cvs/src/src/gold/gold.cc,v
retrieving revision 1.78
diff -p -u -r1.78 gold.cc
--- gold.cc	12 Feb 2010 04:33:53 -0000	1.78
+++ gold.cc	23 Feb 2010 17:40:51 -0000
@@ -532,6 +532,15 @@ queue_middle_tasks(const General_options
         }
     }
 
+  // If we failed to open any input files, it's possible for
+  // THIS_BLOCKER to be NULL here.  There's no real point in
+  // continuing if that happens.
+  if (this_blocker == NULL)
+    {
+      gold_assert(parameters->errors()->error_count() > 0);
+      gold_exit(false);
+    }
+
   // When all those tasks are complete, we can start laying out the
   // output file.
   // TODO(csilvers): figure out a more principled way to get the target
Index: workqueue.h
===================================================================
RCS file: /cvs/src/src/gold/workqueue.h,v
retrieving revision 1.13
diff -p -u -r1.13 workqueue.h
--- workqueue.h	14 Dec 2009 19:53:05 -0000	1.13
+++ workqueue.h	23 Feb 2010 17:40:51 -0000
@@ -152,7 +152,7 @@ class Task_function : public Task
   Task_function(Task_function_runner* runner, Task_token* blocker,
 		const char* name)
     : runner_(runner), blocker_(blocker), name_(name)
-  { }
+  { gold_assert(blocker != NULL); }
 
   ~Task_function()
   {

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]