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: [PATCH][GOLD] Fix dangling pointer bug due to premature unlock.


"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


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