diff options
author | Tom Tromey <tom@tromey.com> | 2024-02-12 18:06:56 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2024-04-16 14:01:43 -0600 |
commit | bacc61fd3e6fd61a59fb59bcc657be17a381520d (patch) | |
tree | 62c1fb63d1e326c4a8f921b7a5a16819626920ef /config/unwind_ipinfo.m4 | |
parent | 6732c57eeea61d72ad1046fae1dd0d00920150e1 (diff) | |
download | gdb-bacc61fd3e6fd61a59fb59bcc657be17a381520d.zip gdb-bacc61fd3e6fd61a59fb59bcc657be17a381520d.tar.gz gdb-bacc61fd3e6fd61a59fb59bcc657be17a381520d.tar.bz2 |
Thread-safety improvements for bfd_check_format_matches
A gdb bug found that bfd_check_format_matches has some data races when
called from multiple threads.
In particular, it changes the BFD error handler, which is a global.
It also has a local static variable ("in_check_format") that is used
for recursion detection. And, finally, it may emit warnings to the
per-xvec warning array, which is a global.
This patch removes all the races here.
The first part of patch is to change _bfd_error_handler to directly
handle the needs of bfd_check_format_matches. This way, the error
handler does not need to be changed.
This change lets us use the new per-thread global
(error_handler_messages, replacing error_handler_bfd) to also remove
the need for in_check_format -- a single variable suffices.
Finally, the global per-xvec array is replaced with a new type that
holds the error messages. The outermost such type is stack-allocated
in bfd_check_format_matches.
I tested this using the binutils test suite. I also built gdb with
thread sanitizer and ran the test case that was noted as failing.
Finally, Alan sent me the test file that caused the addition of the
xvec warning code in the first place, and I confirmed that "nm-new"
has the same behavior on this file both before and after this patch.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31264
Co-Authored-By: Alan Modra <amodra@gmail.com>
Diffstat (limited to 'config/unwind_ipinfo.m4')
0 files changed, 0 insertions, 0 deletions