Skip to content

init: clamp -lowmem to non-negative before assigning to size_t#295

Open
kwsantiago wants to merge 1 commit intobitcoinknots:29.x-knotsfrom
privkeyio:fix-lowmem-negative-wrap
Open

init: clamp -lowmem to non-negative before assigning to size_t#295
kwsantiago wants to merge 1 commit intobitcoinknots:29.x-knotsfrom
privkeyio:fix-lowmem-negative-wrap

Conversation

@kwsantiago
Copy link
Copy Markdown

Summary

  • Negative -lowmem values (e.g. -lowmem=-1) wrap to near-SIZE_MAX when assigned to size_t, causing SystemNeedsMemoryReleased() to always return true
  • Node enters perpetual cache flushing loop
  • Clamp to non-negative with std::max(int64_t{0}, ...) before the multiplication

Test plan

  • Unit tests (validation_chainstate_tests): pass

Negative values wrap to near-SIZE_MAX when assigned to size_t,
causing SystemNeedsMemoryReleased() to always return true.
@luke-jr luke-jr added the bug label Apr 3, 2026
@luke-jr luke-jr added this to the 29.3 (2nd) milestone Apr 10, 2026
Copy link
Copy Markdown
Collaborator

@luke-jr luke-jr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 922bc46

luke-jr pushed a commit that referenced this pull request Apr 13, 2026
Negative values wrap to near-SIZE_MAX when assigned to size_t,
causing SystemNeedsMemoryReleased() to always return true.

Github-Pull: #295
Rebased-From: 922bc46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants