From: Alan Modra <amodra@gmail.com>
To: Tom Tromey <tom@tromey.com>
Cc: binutils@sourceware.org
Subject: Re: [PATCH v2 1/2] Thread-safety improvements for bfd_check_format_matches
Date: Tue, 16 Apr 2024 12:43:48 +0930 [thread overview]
Message-ID: <Zh3s7MoQfC/FsVjH@squeak.grove.modra.org> (raw)
In-Reply-To: <20240415182328.2754398-2-tom@tromey.com>
You need this or something like it on top of your patch, otherwise
the first element with PER_XVEC_NO_TARGET won't have targ set (and the
first element will be used for everything).
diff --git a/bfd/bfd.c b/bfd/bfd.c
index 80ce859d874..ace2f67954f 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -1574,10 +1574,10 @@ INTERNAL
. char message[];
.};
.
-.{* A list of per_xvec_message objects. The targ field
-. indicates which xvec this list holds; PER_XVEC_NO_TARGET
-. indicates that this entry isn't yet used. The abfd field is
-. only needed in the root entry of the list. *}
+.{* A list of per_xvec_message objects. The targ field indicates
+. which xvec this list holds; PER_XVEC_NO_TARGET is only set for the
+. root of the list and indicates that the entry isn't yet used. The
+. abfd field is only needed in the root entry of the list. *}
.struct per_xvec_messages
.{
. bfd *abfd;
@@ -1600,12 +1600,15 @@ _bfd_per_xvec_warn (struct per_xvec_messages *messages, size_t alloc)
struct per_xvec_messages *prev = NULL;
struct per_xvec_messages *iter = messages;
- for (iter = messages; iter != NULL; iter = iter->next)
- {
- if (iter->targ == targ || iter->targ == PER_XVEC_NO_TARGET)
- break;
- prev = iter;
- }
+ if (iter->targ == PER_XVEC_NO_TARGET)
+ iter->targ = targ;
+ else
+ for (; iter != NULL; iter = iter->next)
+ {
+ if (iter->targ == targ)
+ break;
+ prev = iter;
+ }
if (iter == NULL)
{
@@ -1618,8 +1621,6 @@ _bfd_per_xvec_warn (struct per_xvec_messages *messages, size_t alloc)
iter->next = NULL;
prev->next = iter;
}
- else if (iter->targ == NULL)
- iter->targ = targ;
struct per_xvec_message **m = &iter->messages;
int count = 0;
--
Alan Modra
Australia Development Lab, IBM
next prev parent reply other threads:[~2024-04-16 3:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-15 18:22 [PATCH v2 0/2] Fix some races seen by thread sanitizer Tom Tromey
2024-04-15 18:22 ` [PATCH v2 1/2] Thread-safety improvements for bfd_check_format_matches Tom Tromey
2024-04-16 3:13 ` Alan Modra [this message]
2024-04-16 19:51 ` Tom Tromey
2024-04-15 18:22 ` [PATCH v2 2/2] Avoid cache race in bfd_check_format_matches Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zh3s7MoQfC/FsVjH@squeak.grove.modra.org \
--to=amodra@gmail.com \
--cc=binutils@sourceware.org \
--cc=tom@tromey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).