[PATCH] Fix races involving _bfd_section_id

Nick Clifton nickc@redhat.com
Mon Dec 9 09:33:15 GMT 2024


Hi Tom,

> BFD's threading approach is that global variables are guarded by a
> lock.  However, while implementing this, I missed _bfd_section_id.  A
> user pointed out, via Thread Sanitizier, that this causes a data race
> when gdb's background DWARF reader is enabled.
> 
> This patch fixes the problem by using the BFD lock in most of the
> appropriate spots.  However, in ppc64_elf_setup_section_lists I chose
> to simply assert that multiple threads are not in use instead.  (Not
> totally sure if this is good, but I don't think this can be called by
> gdb.)
> 
> I chose locking in bfd_check_format_matches, even though it is a
> relatively big hammer, because it seemed like the most principled
> approach, and anyway if this causes severe contention we can always
> revisit the decision.  Also this approach means we don't need to add
> configury to check for _Atomic, or figure out whether bfd_section_init
> can be reworded to make "rollback" unnecessary.
> 
> I couldn't reproduce these data races but the original reporter tested
> the patch and confirms that it helps.
> 
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31713

This looks OK to me.  If noone else has objected, then please go ahead and apply.

Cheers
   Nick



More information about the Binutils mailing list