From bf406a53693ef664b7ee0c77c4940a71a83866c5 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Thu, 11 Jul 2024 19:29:04 -0700 Subject: libbacktrace: avoid infinite recursion We could get an infinite recursion in an odd case in which a .gnu_debugdata section was added to a debug file, and mini_debuginfo was put into the debug file, and the debug file was put into a /usr/lib/debug directory to be found by build ID. This combination doesn't really make sense but we shouldn't get an infinite recursion. * elf.c (elf_add): Don't use .gnu_debugdata if we are already reading a debuginfo file. * Makefile.am (m2test_*): New test targets. (CHECK_PROGRAMS): Add m2test. (MAKETESTS): Add m2test_minidebug2. (%_minidebug2): New pattern. (CLEANFILES): Remove minidebug2 files. * Makefile.in: Regenerate. --- libbacktrace/elf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libbacktrace/elf.c') diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c index e6a66c0..107c968 100644 --- a/libbacktrace/elf.c +++ b/libbacktrace/elf.c @@ -6841,7 +6841,8 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor, } } - if (!gnu_debugdata_view_valid + if (!debuginfo + && !gnu_debugdata_view_valid && strcmp (name, ".gnu_debugdata") == 0) { if (!elf_get_view (state, descriptor, memory, memory_size, -- cgit v1.1