What changed, and why it matters
This commit is a wholesale revert of a previous merge (pr3764). It undoes a large set of changes across documentation, comments, and several source files. The reverted code appears to have been a mix of typo corrections, minor cleanups, and some functional changes to latency tracking, job-result handling, thread cleanup, and memory management. Because the commit removes those changes rather than introducing new behavior, it does not by itself create a security vulnerability. It may restore older, potentially less safe patterns (for example, calling thread join without checking joinability, or removing safeguards in the job-results queue), but the commit message gives no security rationale and there is no direct evidence of an exploitable flaw being introduced here.
Treat this as a routine revert, not a security fix. If the reverted merge (pr3764) contained functional hardening, review the original PR and any related issue discussions to determine whether the revert reintroduces bugs or unsafe behavior. Run normal regression tests, especially around shutdown, OpenCL/CUDA job-result processing, and memory cleanup. No emergency patching is indicated by this commit alone.
Security signals we found
Revert of prior merge without security explanation
Restoration of unchecked thread join in Thread.h destructor
Removal of bounded queues and lifecycle stop() in JobResults.cpp
Removal of generated_code large-page cleanup in CnCtx::release
No CVE, advisory, or researcher attribution in commit or supplied references
Evidence from the diff
Commit db24bf51 reverts merge commit 0d9a372e (pr3764). The diff is dominated by documentation/comment typo reverts and a handful of code reverts: Thread.h no longer checks joinable() before join(); NetworkState switches from a fixed-size latency ring buffer to an unbounded std::vector; Controller.cpp stops the miner before resetting the network again; CnCtx::release no longer frees generated_code large pages; VirtualMemory::destroy no longer nulls the pool pointer; JobResults.cpp loses queue-size limits, atomic pending-async gating, a stop() lifecycle, and baton ownership, returning to a simpler listener-pointer model. None of these reverts are described by the author as security fixes or as responses to a vulnerability report. The changes are consistent with backing out a merge that was found to cause regressions or instability, not with a security patch.
Changed components
src/backend/common/Thread.hsrc/base/net/stratum/NetworkState.cpp/hsrc/core/Controller.cppsrc/crypto/cn/CnCtx.cppsrc/crypto/common/VirtualMemory.cppsrc/net/JobResults.cppdoc/*.md and OpenCL source commentsInspect captured patch +70 / −241
diff --git a/.codespellrc b/.codespellrc
deleted file mode 100644
index d0a830b..0000000
--- a/.codespellrc
+++ /dev/null
@@ -1,3 +0,0 @@
-[codespell]
-skip = ./src/3rdparty,./src/crypto/ghostrider,./src/crypto/randomx/blake2,./src/crypto/cn/sse2neon.h,./src/backend/opencl/cl/cn/groestl256.cl,./src/backend/opencl/cl/cn/jh.cl
-ignore-words-list = Carmel,vor
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 248fc8b..dc25c1b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -160,7 +160,7 @@
# v6.16.2
- [#2751](https://github.com/xmrig/xmrig/pull/2751) Fixed crash on CPUs supporting VAES and running GCC-compiled xmrig.
- [#2761](https://github.com/xmrig/xmrig/pull/2761) Fixed broken auto-tuning in GCC Windows build.
-- [#2771](https://github.com/xmrig/xmrig/issues/2771) Fixed environment variables support for GhostRider and KawPow.
+- [#2771](https://github.com/xmrig/xmrig/issues/2771) Fixed environment variables support for GhostRider and KawPow.
- [#2769](https://github.com/xmrig/xmrig/pull/2769) Performance fixes:
- Fixed several performance bottlenecks introduced in v6.16.1.
- Fixed overall GCC-compiled build performance, it's the same speed as MSVC build now.
@@ -468,7 +468,7 @@
- Compiler for Windows gcc builds updated to v10.1.
# v5.11.1
-- [#1652](https://github.com/xmrig/xmrig/pull/1652) Up to 1% RandomX performance improvement on recent AMD CPUs.
+- [#1652](https://github.com/xmrig/xmrig/pull/1652) Up to 1% RandomX perfomance improvement on recent AMD CPUs.
- [#1306](https://github.com/xmrig/xmrig/issues/1306) Fixed possible double connection to a pool.
- [#1654](https://github.com/xmrig/xmrig/issues/1654) Fixed build with LibreSSL.
@@ -574,9 +574,9 @@
- Added automatic huge pages configuration on Linux if use the miner with root privileges.
- **Added [automatic Intel prefetchers configuration](https://xmrig.com/docs/miner/randomx-optimization-guide#intel-specific-optimizations) on Linux.**
- Added new option `wrmsr` in `randomx` object with command line equivalent `--randomx-wrmsr=6`.
-- [#1396](https://github.com/xmrig/xmrig/pull/1396) [#1401](https://github.com/xmrig/xmrig/pull/1401) New performance optimizations for Ryzen CPUs.
-- [#1385](https://github.com/xmrig/xmrig/issues/1385) Added `max-threads-hint` option support for RandomX dataset initialization threads.
-- [#1386](https://github.com/xmrig/xmrig/issues/1386) Added `priority` option support for RandomX dataset initialization threads.
+- [#1396](https://github.com/xmrig/xmrig/pull/1396) [#1401](https://github.com/xmrig/xmrig/pull/1401) New performance optimizations for Ryzen CPUs.
+- [#1385](https://github.com/xmrig/xmrig/issues/1385) Added `max-threads-hint` option support for RandomX dataset initialization threads.
+- [#1386](https://github.com/xmrig/xmrig/issues/1386) Added `priority` option support for RandomX dataset initialization threads.
- For official builds all dependencies (libuv, hwloc, openssl) updated to recent versions.
- Windows `msvc` builds now use Visual Studio 2019 instead of 2017.
@@ -622,7 +622,7 @@ This release based on 4.x.x series and include all features from v4.6.2-beta, ch
- Removed command line option `--http-enabled`, HTTP API enabled automatically if any other `--http-*` option provided.
- [#1172](https://github.com/xmrig/xmrig/issues/1172) **Added OpenCL mining backend.**
- [#268](https://github.com/xmrig/xmrig-amd/pull/268) [#270](https://github.com/xmrig/xmrig-amd/pull/270) [#271](https://github.com/xmrig/xmrig-amd/pull/271) [#273](https://github.com/xmrig/xmrig-amd/pull/273) [#274](https://github.com/xmrig/xmrig-amd/pull/274) [#1171](https://github.com/xmrig/xmrig/pull/1171) Added RandomX support for OpenCL, thanks [@SChernykh](https://github.com/SChernykh).
-- Algorithm `cn/wow` removed, as no longer alive.
+- Algorithm `cn/wow` removed, as no longer alive.
# Previous versions
[doc/CHANGELOG_OLD.md](doc/CHANGELOG_OLD.md)
diff --git a/doc/API.md b/doc/API.md
index acfc64b..2cd0fbb 100644
--- a/doc/API.md
+++ b/doc/API.md
@@ -1,8 +1,8 @@
# HTTP API
-If you want use HTTP API you need enable it (`"enabled": true,`) then choice `port` and optionally `host`. API not available if miner built without HTTP support (`-DWITH_HTTP=OFF`).
+If you want use HTTP API you need enable it (`"enabled": true,`) then choice `port` and optionaly `host`. API not available if miner built without HTTP support (`-DWITH_HTTP=OFF`).
-Official HTTP client for API: http://workers.xmrig.info/
+Offical HTTP client for API: http://workers.xmrig.info/
Example configuration:
diff --git a/doc/BENCHMARK.md b/doc/BENCHMARK.md
index 3822fbc..63b6792 100644
--- a/doc/BENCHMARK.md
+++ b/doc/BENCHMARK.md
@@ -17,7 +17,7 @@ Double check that you see `Huge pages 100%` both for dataset and for all threads
### Benchmark with custom config
-You can run benchmark with any configuration you want. Just start without command line parameters, use regular config.json and add `"benchmark":"1M",` on the next line after pool url.
+You can run benchmark with any configuration you want. Just start without command line parameteres, use regular config.json and add `"benchmark":"1M",` on the next line after pool url.
# Stress test
@@ -26,4 +26,4 @@ You can also run continuous stress-test that is as close to the real RandomX min
xmrig --stress
xmrig --stress -a rx/wow
```
-This will require Internet connection and will run indefinitely.
+This will require Internet connection and will run indefinitely.
\ No newline at end of file
diff --git a/doc/CHANGELOG_OLD.md b/doc/CHANGELOG_OLD.md
index 6479737..a799cb3 100644
--- a/doc/CHANGELOG_OLD.md
+++ b/doc/CHANGELOG_OLD.md
@@ -57,7 +57,7 @@
# v4.0.0-beta
- [#1172](https://github.com/xmrig/xmrig/issues/1172) **Added OpenCL mining backend.**
- [#268](https://github.com/xmrig/xmrig-amd/pull/268) [#270](https://github.com/xmrig/xmrig-amd/pull/270) [#271](https://github.com/xmrig/xmrig-amd/pull/271) [#273](https://github.com/xmrig/xmrig-amd/pull/273) [#274](https://github.com/xmrig/xmrig-amd/pull/274) [#1171](https://github.com/xmrig/xmrig/pull/1171) Added RandomX support for OpenCL, thanks [@SChernykh](https://github.com/SChernykh).
-- Algorithm `cn/wow` removed, as no longer alive.
+- Algorithm `cn/wow` removed, as no longer alive.
# v3.2.0
- Added per pool option `coin` with single possible value `monero` for pools without algorithm negotiation, for upcoming Monero fork.
@@ -103,7 +103,7 @@
- [#1105](https://github.com/xmrig/xmrig/issues/1105) Improved auto configuration for `cn-pico` algorithm.
- Added commands `pause` and `resume` via JSON RPC 2.0 API (`POST /json_rpc`).
- Added command line option `--export-topology` for export hwloc topology to a XML file.
-- Broken backward compatibility with previous configs and command line, `variant` option replaced to `algo`, global option `algo` removed, all CPU related settings moved to `cpu` object.
+- Breaked backward compatibility with previous configs and command line, `variant` option replaced to `algo`, global option `algo` removed, all CPU related settings moved to `cpu` object.
- Options `av`, `safe` and `max-cpu-usage` removed.
- Algorithm `cn/msr` renamed to `cn/fast`.
- Algorithm `cn/xtl` removed.
@@ -122,7 +122,7 @@
- [#1092](https://github.com/xmrig/xmrig/issues/1092) Fixed crash if wrong CPU affinity used.
- [#1103](https://github.com/xmrig/xmrig/issues/1103) Improved auto configuration for RandomX for CPUs where L2 cache is limiting factor.
- [#1105](https://github.com/xmrig/xmrig/issues/1105) Improved auto configuration for `cn-pico` algorithm.
-- [#1106](https://github.com/xmrig/xmrig/issues/1106) Fixed `hugepages` field in summary API.
+- [#1106](https://github.com/xmrig/xmrig/issues/1106) Fixed `hugepages` field in summary API.
- Added alternative short format for CPU threads.
- Changed format for CPU threads with intensity above 1.
- Name for reference RandomX configuration changed to `rx/test` to avoid potential conflicts in future.
@@ -150,7 +150,7 @@
- [#1050](https://github.com/xmrig/xmrig/pull/1050) Added RandomXL algorithm for [Loki](https://loki.network/), algorithm name used by miner is `randomx/loki` or `rx/loki`.
- Added [flexible](https://github.com/xmrig/xmrig/blob/evo/doc/CPU.md) multi algorithm configuration.
- Added unlimited switching between incompatible algorithms, all mining options can be changed in runtime.
-- Broken backward compatibility with previous configs and command line, `variant` option replaced to `algo`, global option `algo` removed, all CPU related settings moved to `cpu` object.
+- Breaked backward compatibility with previous configs and command line, `variant` option replaced to `algo`, global option `algo` removed, all CPU related settings moved to `cpu` object.
- Options `av`, `safe` and `max-cpu-usage` removed.
- Algorithm `cn/msr` renamed to `cn/fast`.
- Algorithm `cn/xtl` removed.
@@ -183,7 +183,7 @@
- [#314](https://github.com/xmrig/xmrig-proxy/issues/314) Added donate over proxy feature.
- Added new option `donate-over-proxy`.
- Added real graceful exit.
-
+
# v2.14.4
- [#992](https://github.com/xmrig/xmrig/pull/992) Fixed compilation with Clang 3.5.
- [#1012](https://github.com/xmrig/xmrig/pull/1012) Fixed compilation with Clang 9.0.
@@ -250,7 +250,7 @@
# v2.8.1
- [#768](https://github.com/xmrig/xmrig/issues/768) Fixed build with Visual Studio 2015.
- [#769](https://github.com/xmrig/xmrig/issues/769) Fixed regression, some ANSI escape sequences was in log with disabled colors.
-- [#777](https://github.com/xmrig/xmrig/issues/777) Better report about pool connection issues.
+- [#777](https://github.com/xmrig/xmrig/issues/777) Better report about pool connection issues.
- Simplified checks for ASM auto detection, only AES support necessary.
- Added missing options to `--help` output.
@@ -259,7 +259,7 @@
- Added global and per thread option `"asm"` and command line equivalent.
- **[#758](https://github.com/xmrig/xmrig/issues/758) Added SSL/TLS support for secure connections to pools.**
- Added per pool options `"tls"` and `"tls-fingerprint"` and command line equivalents.
-- [#767](https://github.com/xmrig/xmrig/issues/767) Added config autosave feature, same with GPU miners.
+- [#767](https://github.com/xmrig/xmrig/issues/767) Added config autosave feature, same with GPU miners.
- [#245](https://github.com/xmrig/xmrig-proxy/issues/245) Fixed API ID collision when run multiple miners on same machine.
- [#757](https://github.com/xmrig/xmrig/issues/757) Fixed send buffer overflow.
@@ -346,7 +346,7 @@
# v2.4.4
- Added libmicrohttpd version to --version output.
- - Fixed bug in signal handler, in some cases miner wasn't shutdown properly.
+ - Fixed bug in singal handler, in some cases miner wasn't shutdown properly.
- Fixed recent MSVC 2017 version detection.
- [#279](https://github.com/xmrig/xmrig/pull/279) Fixed build on some macOS versions.
@@ -359,7 +359,7 @@
# v2.4.2
- [#60](https://github.com/xmrig/xmrig/issues/60) Added FreeBSD support, thanks [vcambur](https://github.com/vcambur).
- [#153](https://github.com/xmrig/xmrig/issues/153) Fixed issues with dwarfpool.com.
-
+
# v2.4.1
- [#147](https://github.com/xmrig/xmrig/issues/147) Fixed comparability with monero-stratum.
@@ -371,7 +371,7 @@
- [#101](https://github.com/xmrig/xmrig/issues/101) Fixed MSVC 2017 (15.3) compile time version detection.
- [#108](https://github.com/xmrig/xmrig/issues/108) Silently ignore invalid values for `donate-level` option.
- [#111](https://github.com/xmrig/xmrig/issues/111) Fixed build without AEON support.
-
+
# v2.3.1
- [#68](https://github.com/xmrig/xmrig/issues/68) Fixed compatibility with Docker containers, was nothing print on console.
@@ -398,7 +398,7 @@
# v2.1.0
- [#40](https://github.com/xmrig/xmrig/issues/40)
Improved miner shutdown, fixed crash on exit for Linux and OS X.
-- Fixed, login request was contain malformed JSON if username or password has some special characters for example `\`.
+- Fixed, login request was contain malformed JSON if username or password has some special characters for example `\`.
- [#220](https://github.com/fireice-uk/xmr-stak-cpu/pull/220) Better support for Round Robin DNS, IP address now always chosen randomly instead of stuck on first one.
- Changed donation address, new [xmrig-proxy](https://github.com/xmrig/xmrig-proxy) is coming soon.
@@ -418,16 +418,16 @@ Improved miner shutdown, fixed crash on exit for Linux and OS X.
- Fixed Windows XP support.
- Fixed regression, option `--no-color` was not fully disable colored output.
- Show resolved pool IP address in miner output.
-
+
# v1.0.1
- Fix broken software AES implementation, app has crashed if CPU not support AES-NI, only version 1.0.0 affected.
# v1.0.0
- Miner complete rewritten in C++ with libuv.
-- This version should be fully compatible (except config file) with previous versions, many new nice features will come in next versions.
-- This is still beta. If you found regression, stability or performance issues or have an idea for new feature please fell free to open new [issue](https://github.com/xmrig/xmrig/issues/new).
+- This version should be fully compatible (except config file) with previos versions, many new nice features will come in next versions.
+- This is still beta. If you found regression, stability or perfomance issues or have an idea for new feature please fell free to open new [issue](https://github.com/xmrig/xmrig/issues/new).
- Added new option `--print-time=N`, print hashrate report every N seconds.
-- New hashrate reports, by default every 60 seconds.
+- New hashrate reports, by default every 60 secons.
- Added Microsoft Visual C++ 2015 and 2017 support.
- Removed dependency on libcurl.
- To compile this version from source please switch to [dev](https://github.com/xmrig/xmrig/tree/dev) branch.
@@ -440,7 +440,7 @@ Improved miner shutdown, fixed crash on exit for Linux and OS X.
- Fixed gcc 7.1 support.
# v0.8.1
-- Added nicehash support, detects automatically by pool URL, for example `cryptonight.eu.nicehash.com:3355` or manually via option `--nicehash`.
+- Added nicehash support, detects automaticaly by pool URL, for example `cryptonight.eu.nicehash.com:3355` or manually via option `--nicehash`.
# v0.8.0
- Added double hash mode, also known as lower power mode. `--av=2` and `--av=4`.
diff --git a/doc/CPU.md b/doc/CPU.md
index 6753491..9cd51b9 100644
--- a/doc/CPU.md
+++ b/doc/CPU.md
@@ -124,7 +124,7 @@ Force enable (`true`) or disable (`false`) hardware AES support. Default value `
Mining threads priority, value from `1` (lowest priority) to `5` (highest possible priority). Default value `null` means miner don't change threads priority at all. Setting priority higher than 2 can make your PC unresponsive.
#### `memory-pool` (since v4.3.0)
-Use continuous, persistent memory block for mining threads, useful for preserve huge pages allocation while algorithm switching. Possible values `false` (feature disabled, by default) or `true` or specific count of 2 MB huge pages. It helps to avoid losing huge pages for scratchpads when RandomX dataset is updated and mining threads restart after a 2-3 days of mining.
+Use continuous, persistent memory block for mining threads, useful for preserve huge pages allocation while algorithm switching. Possible values `false` (feature disabled, by default) or `true` or specific count of 2 MB huge pages. It helps to avoid loosing huge pages for scratchpads when RandomX dataset is updated and mining threads restart after a 2-3 days of mining.
#### `yield` (since v5.1.1)
Prefer system better system response/stability `true` (default value) or maximum hashrate `false`.
@@ -133,7 +133,7 @@ Prefer system better system response/stability `true` (default value) or maximum
Enable/configure or disable ASM optimizations. Possible values: `true`, `false`, `"intel"`, `"ryzen"`, `"bulldozer"`.
#### `argon2-impl` (since v3.1.0)
-Allow override automatically detected Argon2 implementation, this option added mostly for debug purposes, default value `null` means autodetect. This is used in RandomX dataset initialization and also in some other mining algorithms. Other possible values: `"x86_64"`, `"SSE2"`, `"SSSE3"`, `"XOP"`, `"AVX2"`, `"AVX-512F"`. Manual selection has no safe guards - if your CPU doesn't support required instructions, miner will crash.
+Allow override automatically detected Argon2 implementation, this option added mostly for debug purposes, default value `null` means autodetect. This is used in RandomX dataset initialization and also in some other mining algorithms. Other possible values: `"x86_64"`, `"SSE2"`, `"SSSE3"`, `"XOP"`, `"AVX2"`, `"AVX-512F"`. Manual selection has no safe guards - if your CPU doesn't support required instuctions, miner will crash.
#### `astrobwt-max-size`
AstroBWT algorithm: skip hashes with large stage 2 size, default: `550`, min: `400`, max: `1200`. Optimal value depends on your CPU/GPU
diff --git a/src/backend/common/Thread.h b/src/backend/common/Thread.h
index 9566446..fb6c618 100644
--- a/src/backend/common/Thread.h
+++ b/src/backend/common/Thread.h
@@ -65,7 +65,7 @@ public:
}
}
# else
- inline ~Thread() { if (m_thread.joinable()) { m_thread.join(); } delete m_worker; }
+ inline ~Thread() { m_thread.join(); delete m_worker; }
inline void start(void *(*callback)(void *)) { m_thread = std::thread(callback, this); }
# endif
diff --git a/src/backend/opencl/cl/cn/cryptonight.cl b/src/backend/opencl/cl/cn/cryptonight.cl
index f7663bb..0385677 100644
--- a/src/backend/opencl/cl/cn/cryptonight.cl
+++ b/src/backend/opencl/cl/cn/cryptonight.cl
@@ -706,7 +706,7 @@ __kernel void cn2(__global uint4 *Scratchpad, __global ulong *states, __global u
}
# if (ALGO_FAMILY == FAMILY_CN_HEAVY)
- /* Also left over threads perform this loop.
+ /* Also left over threads performe this loop.
* The left over thread results will be ignored
*/
#pragma unroll 16
@@ -1005,7 +1005,7 @@ __kernel void Groestl(__global ulong *states, __global uint *BranchBuf, __global
ulong State[8] = { 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0x0001000000000000UL };
ulong H[8], M[8];
- // BUG: AMD driver 19.7.X crashes if this is written as loop
+ // BUG: AMD driver 19.7.X crashs if this is written as loop
// Thx AMD for so bad software
{
((ulong8 *)M)[0] = vload8(0, states);
diff --git a/src/backend/opencl/cl/cn/wolf-skein.cl b/src/backend/opencl/cl/cn/wolf-skein.cl
index 1cf43eb..61efd4b 100644
--- a/src/backend/opencl/cl/cn/wolf-skein.cl
+++ b/src/backend/opencl/cl/cn/wolf-skein.cl
@@ -10,7 +10,7 @@
#else
# define STATIC
/* taken from https://www.khronos.org/registry/OpenCL/extensions/amd/cl_amd_media_ops.txt
- * Built-in Function
+ * Build-in Function
* uintn amd_bitalign (uintn src0, uintn src1, uintn src2)
* Description
* dst.s0 = (uint) (((((long)src0.s0) << 32) | (long)src1.s0) >> (src2.s0 & 31))
diff --git a/src/backend/opencl/cl/kawpow/kawpow.cl b/src/backend/opencl/cl/kawpow/kawpow.cl
index 70bc24d..8f914e8 100644
--- a/src/backend/opencl/cl/kawpow/kawpow.cl
+++ b/src/backend/opencl/cl/kawpow/kawpow.cl
@@ -77,7 +77,7 @@ void keccak_f800_round(uint32_t st[25], const int r)
void keccak_f800(uint32_t* st)
{
// Complete all 22 rounds as a separate impl to
- // evaluate only first 8 words is wasteful of registers
+ // evaluate only first 8 words is wasteful of regsters
for (int r = 0; r < 22; r++) {
keccak_f800_round(st, r);
}
@@ -181,7 +181,7 @@ __kernel void progpow_search(__global dag_t const* g_dag, __global uint* job_blo
for (int i = 10; i < 25; i++)
state[i] = ravencoin_rndc[i-10];
- // Run initial keccak round
+ // Run intial keccak round
keccak_f800(state);
for (int i = 0; i < 8; i++)
diff --git a/src/base/crypto/sha3.cpp b/src/base/crypto/sha3.cpp
index 6879719..d05f9b6 100644
--- a/src/base/crypto/sha3.cpp
+++ b/src/base/crypto/sha3.cpp
@@ -48,7 +48,7 @@
#define KECCAK_ROUNDS 24
-/* *************************** Public Interface ************************ */
+/* *************************** Public Inteface ************************ */
/* For Init or Reset call these: */
sha3_return_t
diff --git a/src/base/net/stratum/NetworkState.cpp b/src/base/net/stratum/NetworkState.cpp
index 4e402eb..40516a7 100644
--- a/src/base/net/stratum/NetworkState.cpp
+++ b/src/base/net/stratum/NetworkState.cpp
@@ -210,7 +210,7 @@ void xmrig::NetworkState::printResults() const
printHashes(m_accepted, m_hashes);
printDiff(m_diff);
- if (m_active && m_latencyCount > 0) {
+ if (m_active && !m_latency.empty()) {
printAvgTime(avgTime());
}
@@ -298,19 +298,13 @@ void xmrig::NetworkState::onResultAccepted(IStrategy *strategy, IClient *client,
uint32_t xmrig::NetworkState::latency() const
{
- const size_t calls = m_latencyCount;
+ const size_t calls = m_latency.size();
if (calls == 0) {
return 0;
}
- std::array<uint16_t, kLatencyWindow> v;
- const size_t start = (m_latencyPos + kLatencyWindow - calls) % kLatencyWindow;
-
- for (size_t i = 0; i < calls; ++i) {
- v[i] = m_latency[(start + i) % kLatencyWindow];
- }
-
- std::nth_element(v.begin(), v.begin() + calls / 2, v.begin() + calls);
+ auto v = m_latency;
+ std::nth_element(v.begin(), v.begin() + calls / 2, v.end());
return v[calls / 2];
}
@@ -318,11 +312,11 @@ uint32_t xmrig::NetworkState::latency() const
uint64_t xmrig::NetworkState::avgTime() const
{
- if (m_latencyCount == 0) {
+ if (m_latency.empty()) {
return 0;
}
- return connectionTime() / m_latencyCount;
+ return connectionTime() / m_latency.size();
}
@@ -348,12 +342,7 @@ void xmrig::NetworkState::add(const SubmitResult &result, const char *error)
std::sort(m_topDiff.rbegin(), m_topDiff.rend());
}
- m_latency[m_latencyPos] = result.elapsed > 0xFFFF ? 0xFFFF : static_cast<uint16_t>(result.elapsed);
- m_latencyPos = (m_latencyPos + 1) % kLatencyWindow;
-
- if (m_latencyCount < kLatencyWindow) {
- m_latencyCount++;
- }
+ m_latency.push_back(result.elapsed > 0xFFFF ? 0xFFFF : static_cast<uint16_t>(result.elapsed));
}
@@ -366,6 +355,5 @@ void xmrig::NetworkState::stop()
m_fingerprint = nullptr;
m_failures++;
- m_latencyCount = 0;
- m_latencyPos = 0;
+ m_latency.clear();
}
diff --git a/src/base/net/stratum/NetworkState.h b/src/base/net/stratum/NetworkState.h
index 8507ab5..d47a351 100644
--- a/src/base/net/stratum/NetworkState.h
+++ b/src/base/net/stratum/NetworkState.h
@@ -27,6 +27,7 @@
#include <array>
#include <string>
+#include <vector>
namespace xmrig {
@@ -59,8 +60,6 @@ protected:
void onResultAccepted(IStrategy *strategy, IClient *client, const SubmitResult &result, const char *error) override;
private:
- constexpr static size_t kLatencyWindow = 1024;
-
uint32_t latency() const;
uint64_t avgTime() const;
uint64_t connectionTime() const;
@@ -71,9 +70,7 @@ private:
bool m_active = false;
char m_pool[256]{};
std::array<uint64_t, 10> m_topDiff { { } };
- std::array<uint16_t, kLatencyWindow> m_latency { { } };
- size_t m_latencyCount = 0;
- size_t m_latencyPos = 0;
+ std::vector<uint16_t> m_latency;
String m_fingerprint;
String m_ip;
String m_tls;
diff --git a/src/core/Controller.cpp b/src/core/Controller.cpp
index 763885f..626175a 100644
--- a/src/core/Controller.cpp
+++ b/src/core/Controller.cpp
@@ -76,12 +76,10 @@ void xmrig::Controller::stop()
{
Base::stop();
- if (m_miner) {
- m_miner->stop();
- m_miner.reset();
- }
-
m_network.reset();
+
+ m_miner->stop();
+ m_miner.reset();
}
diff --git a/src/crypto/cn/CnCtx.cpp b/src/crypto/cn/CnCtx.cpp
index ceace2b..c0dc8b3 100644
--- a/src/crypto/cn/CnCtx.cpp
+++ b/src/crypto/cn/CnCtx.cpp
@@ -49,15 +49,6 @@ void xmrig::CnCtx::release(cryptonight_ctx **ctx, size_t count)
}
for (size_t i = 0; i < count; ++i) {
- if (ctx[i] && ctx[i]->generated_code) {
-# ifdef XMRIG_OS_WIN
- VirtualMemory::freeLargePagesMemory(reinterpret_cast<void *>(ctx[i]->generated_code), 0);
-# else
- VirtualMemory::freeLargePagesMemory(reinterpret_cast<void *>(ctx[i]->generated_code), 0x4000);
-# endif
- ctx[i]->generated_code = nullptr;
- }
-
_mm_free(ctx[i]);
}
}
diff --git a/src/crypto/cn/c_jh.c b/src/crypto/cn/c_jh.c
index ba3fbc0..9e4e7ef 100644
--- a/src/crypto/cn/c_jh.c
+++ b/src/crypto/cn/c_jh.c
@@ -235,7 +235,7 @@ static HashReturn Init(hashState *state, int hashbitlen)
/*initialize the initial hash value of JH*/
state->hashbitlen = hashbitlen;
- /*load the initial hash value into state*/
+ /*load the intital hash value into state*/
switch (hashbitlen)
{
case 224: memcpy(state->x,JH224_H0,128); break;
diff --git a/src/crypto/cn/skein_port.h b/src/crypto/cn/skein_port.h
index 071b37c..4b521c7 100644
--- a/src/crypto/cn/skein_port.h
+++ b/src/crypto/cn/skein_port.h
@@ -48,7 +48,7 @@
multiple of size / 8)
ptr_cast(x,size) casts a pointer to a pointer to a
- variable of length 'size' bits
+ varaiable of length 'size' bits
*/
#define ui_type(size) uint##size##_t
diff --git a/src/crypto/common/VirtualMemory.cpp b/src/crypto/common/VirtualMemory.cpp
index 437b63c..d7d3a54 100644
--- a/src/crypto/common/VirtualMemory.cpp
+++ b/src/crypto/common/VirtualMemory.cpp
@@ -124,7 +124,6 @@ uint32_t xmrig::VirtualMemory::bindToNUMANode(int64_t)
void xmrig::VirtualMemory::destroy()
{
delete pool;
- pool = nullptr;
}
diff --git a/src/crypto/randomx/aes_hash.cpp b/src/crypto/randomx/aes_hash.cpp
index 97b12cd..0b06871 100644
--- a/src/crypto/randomx/aes_hash.cpp
+++ b/src/crypto/randomx/aes_hash.cpp
@@ -86,7 +86,7 @@ void hashAes1Rx4(const void *input, size_t inputSize, void *hash)
rx_vec_i128 state0, state1, state2, state3;
rx_vec_i128 in0, in1, in2, in3;
- //initial state
+ //intial state
state0 = rx_set_int_vec_i128(AES_HASH_1R_STATE0);
state1 = rx_set_int_vec_i128(AES_HASH_1R_STATE1);
state2 = rx_set_int_vec_i128(AES_HASH_1R_STATE2);
diff --git a/src/crypto/randomx/intrin_portable.h b/src/crypto/randomx/intrin_portable.h
index a24c21a..7e3641e 100644
--- a/src/crypto/randomx/intrin_portable.h
+++ b/src/crypto/randomx/intrin_portable.h
@@ -174,7 +174,7 @@ FORCE_INLINE void rx_set_rounding_mode(uint32_t mode) {
_mm_setcsr(rx_mxcsr_default | (mode << 13));
}
-#elif defined(__PPC64__) && defined(__ALTIVEC__) && defined(__VSX__) //sadly only POWER7 and newer will be able to use SIMD acceleration. Earlier processors can't use doubles or 64 bit integers with SIMD
+#elif defined(__PPC64__) && defined(__ALTIVEC__) && defined(__VSX__) //sadly only POWER7 and newer will be able to use SIMD acceleration. Earlier processors cant use doubles or 64 bit integers with SIMD
#include <cstdint>
#include <stdexcept>
#include <cstdlib>
diff --git a/src/crypto/randomx/randomx.h b/src/crypto/randomx/randomx.h
index fb03769..70abff3 100644
--- a/src/crypto/randomx/randomx.h
+++ b/src/crypto/randomx/randomx.h
@@ -231,7 +231,7 @@ RANDOMX_EXPORT unsigned long randomx_dataset_item_count(void);
*
* @param dataset is a pointer to a previously allocated randomx_dataset structure. Must not be NULL.
* @param cache is a pointer to a previously allocated and initialized randomx_cache structure. Must not be NULL.
- * @param startItem is the item number where initialization should start.
+ * @param startItem is the item number where intialization should start.
* @param itemCount is the number of items that should be initialized.
*/
RANDOMX_EXPORT void randomx_init_dataset(randomx_dataset *dataset, randomx_cache *cache, unsigned long startItem, unsigned long itemCount);
diff --git a/src/net/JobResults.cpp b/src/net/JobResults.cpp
index d1a78a4..57e4a8d 100644
--- a/src/net/JobResults.cpp
+++ b/src/net/JobResults.cpp
@@ -56,7 +56,6 @@
#include <cassert>
-#include <atomic>
#include <list>
#include <memory>
#include <mutex>
@@ -67,9 +66,6 @@ namespace xmrig {
#if defined(XMRIG_FEATURE_OPENCL) || defined(XMRIG_FEATURE_CUDA)
-class JobResultsPrivate;
-
-
class JobBundle
{
public:
@@ -90,14 +86,14 @@ public:
class JobBaton : public Baton<uv_work_t>
{
public:
- inline JobBaton(std::list<JobBundle> &&bundles, JobResultsPrivate *owner, bool hwAES) :
+ inline JobBaton(std::list<JobBundle> &&bundles, IJobResultListener *listener, bool hwAES) :
hwAES(hwAES),
- owner(owner),
+ listener(listener),
bundles(std::move(bundles))
{}
const bool hwAES;
- JobResultsPrivate *owner;
+ IJobResultListener *listener;
std::list<JobBundle> bundles;
std::vector<JobResult> results;
uint32_t errors = 0;
@@ -192,8 +188,6 @@ static void getResults(JobBundle &bundle, std::vector<JobResult> &results, uint3
checkHash(bundle, results, nonce, hash, errors);
}
-
- CnCtx::release(ctx, 1);
}
delete memory;
@@ -206,11 +200,6 @@ class JobResultsPrivate : public IAsyncListener
public:
XMRIG_DISABLE_COPY_MOVE_DEFAULT(JobResultsPrivate)
- constexpr static size_t kMaxQueuedResults = 4096;
-# if defined(XMRIG_FEATURE_OPENCL) || defined(XMRIG_FEATURE_CUDA)
- constexpr static size_t kMaxQueuedBundles = 256;
-# endif
-
inline JobResultsPrivate(IJobResultListener *listener, bool hwAES) :
m_hwAES(hwAES),
m_listener(listener)
@@ -225,20 +214,9 @@ public:
inline void submit(const JobResult &result)
{
std::lock_guard<std::mutex> lock(m_mutex);
-
- if (m_stopping) {
- return;
- }
-
- if (m_results.size() >= kMaxQueuedResults) {
- return;
- }
-
m_results.push_back(result);
- if (m_async && !m_pendingAsync.exchange(true)) {
- m_async->send();
- }
+ m_async->send();
}
@@ -246,55 +224,13 @@ public:
inline void submit(const Job &job, uint32_t *results, size_t count, uint32_t device_index)
{
std::lock_guard<std::mutex> lock(m_mutex);
-
- if (count > 0xFF) {
- count = 0xFF;
- }
-
- if (m_stopping) {
- return;
- }
-
- if (m_bundles.size() >= kMaxQueuedBundles) {
- return;
- }
-
m_bundles.emplace_back(job, results, count, device_index);
- if (m_async && !m_pendingAsync.exchange(true)) {
- m_async->send();
- }
+ m_async->send();
}
# endif
- inline void stop()
- {
- bool deleteNow = false;
-
- {
- std::lock_guard<std::mutex> lock(m_mutex);
- m_stopping = true;
- m_listener = nullptr;
- m_results.clear();
-
-# if defined(XMRIG_FEATURE_OPENCL) || defined(XMRIG_FEATURE_CUDA)
- m_bundles.clear();
- m_workScheduled = false;
- m_deleteWhenDone = true;
- deleteNow = (m_pendingWork == 0);
-# else
- deleteNow = true;
-# endif
- }
-
- if (deleteNow) {
- m_async.reset();
- delete this;
- }
- }
-
-
protected:
inline void onAsync() override { submit(); }
@@ -303,92 +239,23 @@ private:
# if defined(XMRIG_FEATURE_OPENCL) || defined(XMRIG_FEATURE_CUDA)
inline void submit()
{
- m_pendingAsync.store(false);
-
std::list<JobBundle> bundles;
std::list<JobResult> results;
m_mutex.lock();
+ m_bundles.swap(bundles);
m_results.swap(results);
-
- const bool canScheduleWork = !m_workScheduled && !m_stopping && !m_bundles.empty();
- if (canScheduleWork) {
- m_bundles.swap(bundles);
- m_workScheduled = true;
- m_pendingWork++;
- }
m_mutex.unlock();
for (const auto &result : results) {
- if (m_listener) {
- m_listener->onJobResult(result);
- }
- }
-
- if (bundles.empty()) {
- return;
- }
-
- auto baton = new JobBaton(std::move(bundles), this, m_hwAES);
-
- uv_queue_work(uv_default_loop(), &baton->req,
- [](uv_work_t *req) {
- auto baton = static_cast<JobBaton*>(req->data);
-
- for (JobBundle &bundle : baton->bundles) {
- getResults(bundle, baton->results, baton->errors, baton->hwAES);
- }
- },
- [](uv_work_t *req, int) {
- auto baton = static_cast<JobBaton*>(req->data);
-
- if (baton->owner) {
- baton->owner->onBatonDone(std::move(baton->results));
- }
-
- delete baton;
- }
- );
- }
-
-
- inline void onBatonDone(std::vector<JobResult> &&results)
- {
- for (const auto &result : results) {
- if (m_listener) {
- m_listener->onJobResult(result);
- }
- }
-
- std::list<JobBundle> bundles;
-
- m_mutex.lock();
-
- m_pendingWork--;
-
- const bool canScheduleWork = !m_stopping && !m_bundles.empty();
- if (canScheduleWork) {
- m_bundles.swap(bundles);
- m_pendingWork++;
- }
- else {
- m_workScheduled = false;
- }
-
- const bool canDelete = m_deleteWhenDone && m_pendingWork == 0;
- m_mutex.unlock();
-
- if (canDelete) {
- m_async.reset();
- delete this;
- return;
+ m_listener->onJobResult(result);
}
if (bundles.empty()) {
return;
}
- auto baton = new JobBaton(std::move(bundles), this, m_hwAES);
+ auto baton = new JobBaton(std::move(bundles), m_listener, m_hwAES);
uv_queue_work(uv_default_loop(), &baton->req,
[](uv_work_t *req) {
@@ -401,8 +268,8 @@ private:
[](uv_work_t *req, int) {
auto baton = static_cast<JobBaton*>(req->data);
- if (baton->owner) {
- baton->owner->onBatonDone(std::move(baton->results));
+ for (const auto &result : baton->results) {
+ baton->listener->onJobResult(result);
}
delete baton;
@@ -412,8 +279,6 @@ private:
# else
inline void submit()
{
- m_pendingAsync.store(false);
-
std::list<JobResult> results;
m_mutex.lock();
@@ -421,9 +286,7 @@ private:
m_mutex.unlock();
for (const auto &result : results) {
- if (m_listener) {
- m_listener->onJobResult(result);
- }
+ m_listener->onJobResult(result);
}
}
# endif
@@ -433,14 +296,9 @@ private:
std::list<JobResult> m_results;
std::mutex m_mutex;
std::shared_ptr<Async> m_async;
- std::atomic<bool> m_pendingAsync{ false };
- bool m_stopping = false;
# if defined(XMRIG_FEATURE_OPENCL) || defined(XMRIG_FEATURE_CUDA)
std::list<JobBundle> m_bundles;
- bool m_workScheduled = false;
- uint32_t m_pendingWork = 0;
- bool m_deleteWhenDone = false;
# endif
};
@@ -467,12 +325,11 @@ void xmrig::JobResults::setListener(IJobResultListener *listener, bool hwAES)
void xmrig::JobResults::stop()
{
- auto h = handler;
- handler = nullptr;
+ assert(handler != nullptr);
- if (h) {
- h->stop();
- }
+ delete handler;
+
+ handler = nullptr;
}
@@ -490,6 +347,8 @@ void xmrig::JobResults::submit(const Job& job, uint32_t nonce, const uint8_t* re
void xmrig::JobResults::submit(const JobResult &result)
{
+ assert(handler != nullptr);
+
if (handler) {
handler->submit(result);
}
Why this scored 12/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.