CI: save a minidump if it hangs on shutdown

This commit is contained in:
SChernykh
2024-07-20 12:49:00 +02:00
parent ce6553863a
commit 37bf8554fc
5 changed files with 33 additions and 2 deletions

View File

@@ -415,12 +415,14 @@ jobs:
- name: Check p2pool.log
run: |
cd build/RelWithDebInfo
Remove-Item p2pool.cache -Force
findstr /C:"Synchronization finished successfully" p2pool.log
- name: Archive p2pool.log
if: '!cancelled()'
uses: actions/upload-artifact@v4
with:
name: p2pool_windows_data_leaks
path: |
build/RelWithDebInfo/*.log
build/RelWithDebInfo/p2pool.*
build/RelWithDebInfo/data/

View File

@@ -436,12 +436,14 @@ jobs:
- name: Check p2pool.log
run: |
cd build/RelWithDebInfo
Remove-Item p2pool.cache -Force
findstr /C:"Synchronization finished successfully" p2pool.log
- name: Archive p2pool.log
if: '!cancelled()'
uses: actions/upload-artifact@v4
with:
name: p2pool_windows_data_leaks
path: |
build/RelWithDebInfo/*.log
build/RelWithDebInfo/p2pool.*
build/RelWithDebInfo/data/

View File

@@ -137,6 +137,27 @@ void show_top_10_allocations()
VirtualFree(buf, 0, MEM_RELEASE);
}
static DWORD WINAPI minidump_and_crash_thread(LPVOID param)
{
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
const size_t delay = reinterpret_cast<size_t>(param);
Sleep(static_cast<DWORD>(delay));
HANDLE h = CreateFile(TEXT("p2pool.dmp"), GENERIC_ALL, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), h, MiniDumpWithHandleData, nullptr, nullptr, nullptr);
CloseHandle(h);
TerminateProcess(GetCurrentProcess(), 123);
return 0;
}
void minidump_and_crash(size_t delay)
{
CreateThread(nullptr, 0, minidump_and_crash_thread, reinterpret_cast<LPVOID>(delay), 0, nullptr);
}
FORCEINLINE static void add_alocation(void* p, size_t size)
{
if (!track_memory) {

View File

@@ -2185,6 +2185,11 @@ void SideChain::prune_old_blocks()
m_pool->print_hosts();
m_pool->stop();
#ifdef DEV_TRACK_MEMORY
// Give it 1 minute to shut down, otherwise save a minidump
minidump_and_crash(60 * 1000);
#endif
}
#endif
}

View File

@@ -358,6 +358,7 @@ FORCEINLINE bool get_dns_txt_records(const std::string& host, T&& callback) { re
#ifdef DEV_TRACK_MEMORY
void show_top_10_allocations();
void minidump_and_crash(size_t delay);
#endif
} // namespace p2pool