AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Moderate 53 Mining software

feat: stability improvements, see detail below

Public commit record

What the developer wrote

Authored by rezky_nightky

100/100 · Strong
feat: stability improvements, see detail below

Key stability improvements made (deterministic + bounded)
1) Bounded memory usage in long-running stats
Fixed unbounded growth in NetworkState latency tracking:
Replaced std::vector<uint16_t> m_latency + push_back() with a fixed-size ring buffer (kLatencyWindow = 1024) and explicit counters.
Median latency computation now operates on at most 1024 samples, preventing memory growth and avoiding performance cliffs from ever-growing copies/sorts.
2) Prevent crash/UAF on shutdown + more predictable teardown
Controller shutdown ordering (Controller::stop()):
Now stops m_miner before destroying m_network.
This reduces chances of worker threads submitting results into a network listener that’s already destroyed.
Thread teardown hardening (backend/common/Thread.h):
Destructor now checks std::thread::joinable() before join().
Avoids std::terminate() if a thread object exists but never started due to early exit/error paths.
3) Fixed real leaks (including executable memory)
Executable memory leak fixed (crypto/cn/CnCtx.cpp):
CnCtx::create() allocates executable memory for generated_code via VirtualMemory::allocateExecutableMemory(0x4000, ...).
Previously CnCtx::release() only _mm_free()’d the struct, leaking the executable mapping.
Now CnCtx::release() frees generated_code before freeing the ctx.
GPU verification leak fixed (net/JobResults.cpp):
In getResults() (GPU result verification), a cryptonight_ctx was created via CnCtx::create() but never released.
Added CnCtx::release(ctx, 1).
4) JobResults: bounded queues + backpressure + safe shutdown semantics
The old JobResults could:

enqueue unlimited std::list items (m_results, m_bundles) → unbounded RAM,
call uv_queue_work per async batch → unbounded libuv threadpool backlog,
delete handler directly while worker threads might still submit → potential crash/UAF.
Changes made:

Hard queue limits:
kMaxQueuedResults = 4096
kMaxQueuedBundles = 256
Excess is dropped (bounded behavior under load).
Async coalescing:
Only one pending async notification at a time (m_pendingAsync), reducing eventfd/uv wake storms.
Bounded libuv work scheduling:
Only one uv_queue_work is scheduled at a time (m_workScheduled), preventing CPU starvation and unpredictable backlog.
Safe shutdown:
JobResults::stop() now detaches global handler first, then calls handler->stop().
Shutdown detaches m_listener, clears queues, and defers deletion until in-flight work is done.
Defensive bound on GPU result count:
Clamp count to 0xFF inside JobResults as well, not just in the caller, to guard against corrupted kernels/drivers.
5) Idempotent cleanup
VirtualMemory::destroy() now sets pool = nullptr after delete:
prevents accidental double-delete on repeated teardown paths.
Verification performed
codespell . --config ./.codespellrc: clean
CMake configure + build completed successfully (Release build)

Signed-off-by: rezky_nightky <with.rezky@gmail.com>
✓ Descriptive subject✓ Names a concrete action or component✓ Uses a recognizable type or scope✓ Provides detailed explanatory context✓ Explains rationale or failure mode✓ Mentions testing or verification
The short version

What changed, and why it matters

This commit is a hardening patch for the XMRig cryptocurrency miner. It fixes several stability problems that could also have security consequences: unbounded memory growth in network statistics, a shutdown crash where worker threads could use an already-destroyed network object, a leak of executable memory used by mining code, a leaked cryptography context during GPU result checking, and unsafe unbounded queues in the job-results processor. The patch adds size limits, safer teardown ordering, and proper cleanup of executable memory and contexts. There is no claim in the commit that these issues are exploitable for code execution or were reported as security vulnerabilities.

Recommended action

Treat this as a worthwhile stability and defense-in-depth patch. Users running long-lived XMRig instances, especially with GPU backends, should upgrade to avoid memory exhaustion, executable-memory leaks, and shutdown crashes. It is not marketed as an urgent security fix, but the executable-memory leak and shutdown races are genuine security-relevant defects. No CVE or advisory is referenced, so routine update scheduling is reasonable unless the deployment is high-assurance, in which case prompt patching is prudent.

Security signals we found

01

Fixes use-after-free / shutdown race by reordering Controller::stop() teardown (miner before network).

02

Fixes std::terminate risk in Thread destructor via joinable() check.

03

Fixes executable memory leak in CnCtx::release() by freeing generated_code.

04

Fixes cryptonight_ctx leak in GPU verification path (JobResults::getResults).

05

Adds bounded queues and backpressure in JobResults to prevent unbounded memory growth and libuv threadpool exhaustion.

06

Adds safe shutdown semantics in JobResults to avoid deleting handler while worker threads may still reference it.

07

Adds defensive clamp of GPU result count to 0xFF to mitigate corrupted kernel/driver input.

08

No vendor statement that these issues are security vulnerabilities or were externally reported.

Risk score

Why this scored 53/100

Our methodology →
Potential impact 18/30
Exploitability 8/25
Stealth signal 6/15
Affected reach 10/15
Confidence 7/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.