Skip to content

fix: windows memory leak - #131

Merged
arun11299 merged 1 commit into
arun11299:masterfrom
Lveyou:master
Mar 27, 2026
Merged

arun11299 merged 1 commit into
arun11299:masterfrom
Lveyou:master

Conversation

@Lveyou

@Lveyou Lveyou commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@arun11299
arun11299 merged commit 695b306 into arun11299:master Mar 27, 2026
fanquake added a commit to bitcoin/bitcoin that referenced this pull request Oct 22, 2026
cf30d0a subprocess: fix command line memory leak on Windows (stickies-v)

Pull request description:

  `Popen::execute_process()` copied the command line into a buffer from `new[]`, but did not delete it. This leaked memory each time a process started on Windows.

  `CreateProcessA` [needs](https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessa#:~:text=characters%2E-,The,violation) a writable command line buffer. Since C++17, `std::string::data()` supplies one, so give the `std::string` buffer directly and remove the copy.

  This only affects Windows. It is only reachable if `-signer=<cmd>` is set, through authenticated RPC or the GUI. Each call leaks only the startup-defined `<cmd>`, and the rate is limited by process spawn time, so the impact is limited.

  _edit: this was fixed upstream in arun11299/cpp-subprocess#131, but since this codebase is C++20 it seems better to avoid the copy (and the const cast). A direct backport isn't possible anyway, since #35704 switched us to CreateProcessA._

ACKs for top commit:
  jpk68:
    ACK cf30d0a
  hebasto:
    re-ACK cf30d0a.
  winterrdog:
    reACK cf30d0a

Tree-SHA512: 873a5b69e4094dfc1cba0f822af1e431f7d6e29f2fac58e0712ffa060296022db0cbff55ab6f7a4416168e4958bcaa1567ad568f2a3a662e3cb4603bbb786816
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants