This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[GOLD][PATCH PROPOSAL] fix segmentation fault in the Task_function class
- From: Viktor Kutuzov <vkutuzov at accesssoftek dot com>
- To: Ian Lance Taylor <iant at google dot com>, binutils <binutils at sourceware dot org>
- Date: Mon, 22 Feb 2010 11:55:09 -0800
- Subject: [GOLD][PATCH PROPOSAL] fix segmentation fault in the Task_function class
- Reply-to: vkutuzov at accesssoftek dot com
Hi everyone,
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
--
-Viktor
Index: workqueue.h
===================================================================
RCS file: /cvs/src/src/gold/workqueue.h,v
retrieving revision 1.13
diff -u -p -r1.13 workqueue.h
--- workqueue.h 14 Dec 2009 19:53:05 -0000 1.13
+++ workqueue.h 19 Feb 2010 19:07:36 -0000
@@ -152,7 +152,10 @@ 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(runner);
+ gold_assert(blocker);
+ }
~Task_function()
{
Index: gold.cc
===================================================================
RCS file: /cvs/src/src/gold/gold.cc,v
retrieving revision 1.78
diff -u -p -r1.78 gold.cc
--- gold.cc 12 Feb 2010 04:33:53 -0000 1.78
+++ gold.cc 19 Feb 2010 19:07:36 -0000
@@ -220,6 +220,10 @@ queue_initial_tasks(const General_option
this_blocker = next_blocker;
}
+ // No blockers were created before, provide one by default.
+ if (this_blocker == NULL)
+ this_blocker = new Task_token(true);
+
if (parameters->options().relocatable()
&& (parameters->options().gc_sections()
|| parameters->options().icf_enabled()))
@@ -532,6 +536,10 @@ queue_middle_tasks(const General_options
}
}
+ // No blockers were created before, provide one by default.
+ if (this_blocker == NULL)
+ this_blocker = new Task_token(true);
+
// 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