From 9628c771ad4835ae186138a3b8f3432efed5ec77 Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Thu, 1 Dec 2022 09:31:44 +0100 Subject: [PATCH] backtrace: Suppress internal errors by libbfd At least since Ubuntu 22.04 there are lots of (apparently non-fatal) "DWARF error: could not find variable specification" errors generated by bfd_find_nearest_line(). This also happens with addr2line, which internally uses libbfd. No idea what the actual issue is (it still happens with binutils 2.39 in Ubuntu 22.10), but since it doesn't seem to affect the functionality we need this avoids filling the test logs with useless messages. --- src/libstrongswan/utils/backtrace.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libstrongswan/utils/backtrace.c b/src/libstrongswan/utils/backtrace.c index 2fdfab1ee..f2631f394 100644 --- a/src/libstrongswan/utils/backtrace.c +++ b/src/libstrongswan/utils/backtrace.c @@ -242,6 +242,15 @@ static bool bfd_equals(char *a, char *b) return streq(a, b); } +/** + * Do not print internal errors by libbfd as we get quite a lot of + * "DWARF error: could not find variable specification" messages when running + * against Ubuntu 20.04's libcrypto (same with addr2line and still in 22.10). + */ +void suppress_bfd_errors (const char *fmt, va_list args) +{ +} + /** * See header. */ @@ -251,6 +260,7 @@ void backtrace_init() bfds = hashtable_create((hashtable_hash_t)bfd_hash, (hashtable_equals_t)bfd_equals, 8); bfd_mutex = mutex_create(MUTEX_TYPE_DEFAULT); + bfd_set_error_handler(suppress_bfd_errors); } /**