[PATCH 3/3] Add minimal thread-safety to BFD

Tom Tromey tom@tromey.com
Wed Nov 1 20:48:03 GMT 2023


Nick> typedef bool (* bfd_lock_unlock_fn_type) (bfd *, void *);

Tom> I suppose the BFD callers can just return if these fail.

Well, I started on this change, but I am not sure about it now.

cache_btell doesn't seem to have any way to even report an error.  So,
I'm not sure what to do there.  Ignoring the failure is no good.

Or, consider things like cache_bseek.  Handling a failure of bfd_lock is
easy, but there's an unlock at the end:

  int result = _bfd_real_fseek (f, offset, whence);
  bfd_unlock ();
  return result;

If that fails should this really return -1?  Similarly for cache_bwrite,
etc.

On the other hand, I don't think these things really can fail.  Like,
pthread_mutex_lock/unlock failures modes all are basically programming
errors.  So this may argue for just "doing anything".  Or we could
declare these to be infallible.

Let me know what you'd prefer.

Tom


More information about the Binutils mailing list