[PATCH][GOLD] Fix dangling pointer bug due to premature unlock.

Doug Kwan (關振德) dougkwan@google.com
Tue Jan 25 15:48:00 GMT 2011


In the name of simplicity, I will change it to always lock then.

Thanks

-Doug

On Tue, Jan 25, 2011 at 7:26 AM, Ian Lance Taylor <iant@google.com> wrote:
> "Doug Kwan (關振德)" <dougkwan@google.com> writes:
>
>>    This fixes a bug in which an object is released too early, causing
>> a pointer to point to unmapped memory.  My fix is to move the locking
>> code to the caller of get_section_contents() and replace the original
>> locking code with a check.  This has been tested on x86_64.
>>
>> -Doug
>>
>>
>> 2011-01-25  Doug Kwan  <dougkwan@google.com>
>>
>>         * gold/icf.cc (get_section_contents): Instead of locking object in
>>         two places, ask caller to lock it before calling. Add an assert
>>         to check that object is locked in the first iteration.
>>         (match_sections): Lock object before calling get_section_contents()
>>         in the first iteration.
>
> This patch is fine.  However, it would be slightly simpler to just
> always lock the object in get_section_contents, regardless of whether
> first_iteration is true or not.  Task locks in gold are not mutexes or
> anything, they are basically free.  There is no reason to be careful to
> only do the lock on the first iteration.
>
> The patch is OK either way.
>
> Thanks.
>
> Ian
>



More information about the Binutils mailing list