From 36d03d19fef8d904f4b45f1dff474d6bfec7c9c8 Mon Sep 17 00:00:00 2001 From: Matt Hess Date: Tue, 9 Dec 2025 03:10:14 +0000 Subject: [PATCH] Fix crash when stratum miners submit with stale templates Added bounds check in get_hashing_blob_nolock() to handle empty m_transactionHashes when old/stale template slots are accessed. Returns 0 and logs at level 3 instead of vector out-of-bounds crash. Primarily affects external stratum miners that may hold onto old job IDs across template updates --- src/block_template.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/block_template.cpp b/src/block_template.cpp index 78f10bc..949f475 100644 --- a/src/block_template.cpp +++ b/src/block_template.cpp @@ -1576,8 +1576,14 @@ uint32_t BlockTemplate::get_hashing_blob_nolock(uint32_t extra_nonce, uint8_t* b hash miner_tx_hash = calc_miner_tx_hash(extra_nonce); const size_t num_hashes = m_transactionHashes.size() / HASH_SIZE; + if (num_hashes == 0) { + LOGERR(3, "get_hashing_blob_nolock: m_transactionHashes is empty"); + return 0; + } + std::vector hashes(num_hashes); hashes[0] = miner_tx_hash; // miner tx with current extra_nonce + for (size_t i = 1; i < num_hashes; ++i) { memcpy(hashes[i].h, m_transactionHashes.data() + i * HASH_SIZE, HASH_SIZE); }