From 55e12a371554ac6669fa9c92b77b2fd98d113504 Mon Sep 17 00:00:00 2001 From: SChernykh <15806605+SChernykh@users.noreply.github.com> Date: Thu, 20 Mar 2025 19:00:02 +0100 Subject: [PATCH] Fixed unaligned memory accesses --- src/console_commands.h | 2 +- src/merge_mining_client_tari.h | 2 +- src/miner.cpp | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/console_commands.h b/src/console_commands.h index 77e8ba1..a1eae80 100644 --- a/src/console_commands.h +++ b/src/console_commands.h @@ -42,7 +42,7 @@ public: bool on_connect() override { return true; }; bool on_read(const char* data, uint32_t size) override { static_cast<ConsoleCommands*>(m_owner)->process_input(m_command, data, size); return true; }; - char m_consoleReadBuf[1024] = {}; + alignas(8) char m_consoleReadBuf[1024] = {}; std::string m_command; }; diff --git a/src/merge_mining_client_tari.h b/src/merge_mining_client_tari.h index 197181b..3b265ae 100644 --- a/src/merge_mining_client_tari.h +++ b/src/merge_mining_client_tari.h @@ -100,7 +100,7 @@ private: [[nodiscard]] bool on_connect() override; [[nodiscard]] bool on_read(const char* data, uint32_t size) override; - char m_buf[BUF_SIZE]; + alignas(8) char m_buf[BUF_SIZE]; std::vector<uint8_t> m_pendingData; bool is_paired() const { return m_pairedClient && (m_pairedClient->m_resetCounter == m_pairedClientSavedResetCounter); } diff --git a/src/miner.cpp b/src/miner.cpp index ecd82c6..91f29ce 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -152,8 +152,16 @@ void Miner::run(void* data) { WorkerData* d = static_cast<WorkerData*>(data); LOGINFO(1, "worker thread " << d->m_index << '/' << d->m_count << " started"); + + char buf[16] = {}; + log::Stream s(buf); + s << "Miner " << d->m_index << '/' << d->m_count; + + set_thread_name(buf); + make_thread_background(); d->m_miner->run(d); + LOGINFO(1, "worker thread " << d->m_index << '/' << d->m_count << " stopped"); }