]> Gentwo Git Trees - linux/.git/commit
perf libbfd: Ensure libbfd is initialized prior to use
authorIan Rogers <irogers@google.com>
Wed, 12 Nov 2025 07:43:11 +0000 (23:43 -0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 13 Nov 2025 20:55:19 +0000 (17:55 -0300)
commitb72b8132d8fd2d6bf5b420a03d4fc553980c3a92
tree9ce044269b742c63c1d993d14e198d667144067a
parent3c723f449723db2dc2b75b7efe03c2a76e4c09f0
perf libbfd: Ensure libbfd is initialized prior to use

Multiple threads may be creating and destroying BFD objects in
situations like `perf top`.

Without appropriate initialization crashes may occur during libbfd's
cache management.

BFD's locks require recursive mutexes, add support for these.

Committer testing:

This happens only when building with 'make BUILD_NONDISTRO=1' and having
the binutils-devel package (or equivalent) installed, i.e. linking with
binutils devel files, an opt-in perf build.

Before:

  root@x1:~# perf top
  perf: Segmentation fault
  -------- backtrace --------
  <SNIP multiple failed attempts at printing a backtrace>
  root@x1:~#

After this patch it works as before.

Closes: https://lore.kernel.org/lkml/aQt66zhfxSA80xwt@gentoo.org/
Fixes: 95931d9a594dd0b5 ("perf libbfd: Move libbfd functionality to its own file")
Reported-by: Guilherme Amadio <amadio@gentoo.org>
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/libbfd.c
tools/perf/util/mutex.c
tools/perf/util/mutex.h