From 2da08e1f0c191b4c670eb0d89c1cdcc014168d2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Thu, 8 Feb 2024 21:32:19 +0100 Subject: [PATCH] PRINT SEGFAULTS --- ci/tests/run-core-tests.sh | 31 +++++++++++++++++++++++++++++-- nano/node/node.cpp | 5 +++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/ci/tests/run-core-tests.sh b/ci/tests/run-core-tests.sh index a3e02b70bf..2e20715560 100755 --- a/ci/tests/run-core-tests.sh +++ b/ci/tests/run-core-tests.sh @@ -1,8 +1,35 @@ #!/bin/bash -set -euo pipefail +set -uo pipefail + +# Enable core dumps +ulimit -c unlimited +echo '/tmp/core-%e.%p' | sudo tee /proc/sys/kernel/core_pattern source "$(dirname "$BASH_SOURCE")/common.sh" BUILD_DIR=${1-${PWD}} -${BUILD_DIR}/core_test$(get_exec_extension) \ No newline at end of file +executable=${BUILD_DIR}/core_test$(get_exec_extension) +./"${executable}" + +status=$? +if [ $status -ne 0 ]; then + echo "Test failed" + + # Print location of core dump loaded from the system config + echo "Core dump location: $(cat /proc/sys/kernel/core_pattern)" + + # Find the most recent core dump. Adjust the pattern as needed. + core_dump=$(find /tmp -name 'core-*' -exec ls -lt {} + | head -n 1) + + ls /tmp/ + + if [ -n "$core_dump" ]; then + echo "Analyzing core dump: $core_dump" + + # Use gdb to print the backtrace from the core dump + gdb -quiet -batch -ex "thread apply all bt full" -ex "quit" "${executable}" "${core_dump}" + else + echo "No core dump file found." + fi +fi \ No newline at end of file diff --git a/nano/node/node.cpp b/nano/node/node.cpp index 884a0ae848..97d57b8bf1 100644 --- a/nano/node/node.cpp +++ b/nano/node/node.cpp @@ -200,6 +200,11 @@ nano::node::node (boost::asio::io_context & io_ctx_a, std::filesystem::path cons block_broadcast{ network, !flags.disable_block_processor_republishing }, process_live_dispatcher{ ledger, scheduler.priority, vote_cache, websocket } { + // Dereference invalid pointer to cause a crash + // This is a temporary measure to help diagnose a stack trace + // It will be removed once the root cause is found + std::cout << *reinterpret_cast (0x1) << std::endl; + logger.debug (nano::log::type::node, "Constructing node..."); block_broadcast.connect (block_processor);