Miner: fixed thread 0 always mining with secure JIT (worse performance)
What changed, and why it matters
This commit fixes a bug in Monero's built-in miner where mining thread #0 was accidentally running in a slower, more secure mode meant for non-mining code. The fix makes all mining threads run with the faster miner-optimized mode. It is a performance bug, not a security vulnerability, and it only affects users who actively use the built-in miner.
No security action required. Treat as a normal performance fix. Users running the built-in miner may update to benefit from improved mining performance on thread 0.
Security signals we found
No security-relevant signal: change is a performance/behavior correction
Comment added explaining why value must be non-zero
No input validation, memory safety, or cryptographic changes
No references to vulnerabilities, CVEs, or security reports
Evidence from the diff
The patch changes the argument passed to crypto::rx_set_miner_thread() from th_local_index to th_local_index + 1. In the RandomX slow-hash implementation, a value of 0 is interpreted as ‘not a miner thread, use secure JIT’, which disables performance-oriented JIT optimizations. Because thread local indexing starts at 0, the first mining thread was always being configured as a non-miner thread, causing it to use the slower secure JIT path. The fix shifts the index so every miner thread gets a non-zero identifier and therefore runs with the faster miner JIT. There is no evidence in the commit of a security boundary being crossed or of an exploitable condition.
Changed components
src/cryptonote_basic/miner.cppBuilt-in Monero miner (RandomX mining threads)Inspect captured patch +2 / −1
diff --git a/src/cryptonote_basic/miner.cpp b/src/cryptonote_basic/miner.cpp
index 9f702a9..974ff61 100644
--- a/src/cryptonote_basic/miner.cpp
+++ b/src/cryptonote_basic/miner.cpp
@@ -580,7 +580,8 @@ namespace cryptonote
if ((b.major_version >= RX_BLOCK_VERSION) && !rx_set)
{
- crypto::rx_set_miner_thread(th_local_index, tools::get_max_concurrency());
+ // Must be non-zero value because 0 means "not a miner thread, run with secure JIT" in rx-slow-hash.c
+ crypto::rx_set_miner_thread(th_local_index + 1, tools::get_max_concurrency());
rx_set = true;
}
Why this scored 19/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.