From 07ae57ad67293f3164d9c8b2b6a50b6e1a77f149 Mon Sep 17 00:00:00 2001 From: Nickolay Olshevsky Date: Tue, 13 Feb 2024 16:58:17 +0200 Subject: [PATCH] Another attempt to debug malloc failure. --- .github/workflows/centos-and-fedora.yml | 2 +- src/tests/ffi.cpp | 28 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/.github/workflows/centos-and-fedora.yml b/.github/workflows/centos-and-fedora.yml index 018d1e26e4..f6db789353 100644 --- a/.github/workflows/centos-and-fedora.yml +++ b/.github/workflows/centos-and-fedora.yml @@ -168,7 +168,7 @@ jobs: cp "cmake/CTestCostData.txt" "build/Testing/Temporary" export PATH="$PWD/build/src/lib:$PATH" chown -R rnpuser:rnpuser $PWD - exec su rnpuser -c "ctest --parallel ${{ env.CORES }} --test-dir build --output-on-failure" + exec su rnpuser -c "LD_PRELOAD=\"/usr/lib64/libc_malloc_debug.so.0:/usr/lib64/libsigsegv.so.2\" ctest --parallel ${{ env.CORES }} --test-dir build --output-on-failure" - name: Coverage if: env.BUILD_MODE == 'coverage' diff --git a/src/tests/ffi.cpp b/src/tests/ffi.cpp index 9fb4e5208c..e519fde941 100644 --- a/src/tests/ffi.cpp +++ b/src/tests/ffi.cpp @@ -6049,10 +6049,38 @@ TEST_F(rnp_tests, test_result_to_string) } } +#include +#include + +void +handler(int sig) +{ + void * array[30]; + size_t size; + char **strings; + size_t i; + + // Get the backtrace + size = backtrace(array, 30); + strings = backtrace_symbols(array, size); + + printf("Caught signal %d:\n", sig); + + // Print stack trace to stderr + for (i = 0; i < size; i++) { + printf("%s\n", strings[i]); + } + + free(strings); + exit(EXIT_FAILURE); +} + TEST_F(rnp_tests, test_ffi_wrong_hex_length) { rnp_ffi_t ffi = NULL; + signal(SIGSEGV, handler); + // setup FFI assert_rnp_success(rnp_ffi_create(&ffi, "GPG", "GPG")); // load our keyrings