Skip to content

Commit

Permalink
Another attempt to debug malloc failure.
Browse files Browse the repository at this point in the history
  • Loading branch information
ni4 committed Feb 15, 2024
1 parent 6840507 commit 07ae57a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/centos-and-fedora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
28 changes: 28 additions & 0 deletions src/tests/ffi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6049,10 +6049,38 @@ TEST_F(rnp_tests, test_result_to_string)
}
}

#include <execinfo.h>
#include <signal.h>

void
handler(int sig)

Check warning on line 6056 in src/tests/ffi.cpp

View check run for this annotation

Codecov / codecov/patch

src/tests/ffi.cpp#L6056

Added line #L6056 was not covered by tests
{
void * array[30];
size_t size;
char **strings;
size_t i;

// Get the backtrace
size = backtrace(array, 30);
strings = backtrace_symbols(array, size);

Check warning on line 6065 in src/tests/ffi.cpp

View check run for this annotation

Codecov / codecov/patch

src/tests/ffi.cpp#L6064-L6065

Added lines #L6064 - L6065 were not covered by tests

printf("Caught signal %d:\n", sig);

Check warning on line 6067 in src/tests/ffi.cpp

View check run for this annotation

Codecov / codecov/patch

src/tests/ffi.cpp#L6067

Added line #L6067 was not covered by tests

// Print stack trace to stderr
for (i = 0; i < size; i++) {
printf("%s\n", strings[i]);

Check warning on line 6071 in src/tests/ffi.cpp

View check run for this annotation

Codecov / codecov/patch

src/tests/ffi.cpp#L6070-L6071

Added lines #L6070 - L6071 were not covered by tests
}

free(strings);
exit(EXIT_FAILURE);

Check warning on line 6075 in src/tests/ffi.cpp

View check run for this annotation

Codecov / codecov/patch

src/tests/ffi.cpp#L6074-L6075

Added lines #L6074 - L6075 were not covered by tests
}

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
Expand Down

0 comments on commit 07ae57a

Please sign in to comment.