Skip to content

Own the .NET forwarder task; release Python memory-tracking state on stop - #57

Merged
MelbourneDeveloper merged 2 commits into
mainfrom
fix/owned-handles-0.7
Nov 18, 2026
Merged

MelbourneDeveloper merged 2 commits into
mainfrom
fix/owned-handles-0.7

Conversation

@MelbourneDeveloper

Copy link
Copy Markdown
Collaborator

This finishes the v0.6.0 leak review. #56 left two items open.

Fixed

  • The .NET forwarder (lsp-profiler-dotnet/src/cpu.rs) was spawned with drop(tokio::spawn(..)), which AGENTS.md forbids. Now SamplerHandle::own_producer keeps the task's abort handle, and dropping the handle aborts the task.
    • Before the fix, sampler_lifetime_tests.rs failed: the producer outlived its dropped sampler handle (left: 1, right: 0).
    • No drop(tokio::spawn( is left in the workspace.
  • The Python stop_tracemalloc script left four things behind in the debuggee: the collected cycles in gc.garbage (DEBUG_SAVEALL), the baseline snapshot, the atexit hook and the signal handlers. It now releases all four.
    • The crate is parked and doesn't build, so the script now lives in src/memory/scripts/stop_tracemalloc.py, pulled in with include_str!.
    • A real-interpreter test, make _python_scripts_test, runs it as part of make test.
    • Every assertion failed against the old script: 62 objects left in gc.garbage, the snapshot still referenced, SIGINT still routed to the profiler, and the exit hook still alive.

Left as they are

These handles end with their owners, so they aren't leaks:

  • The pyspy.rs sampler thread stops when the handle's Drop sets the stop flag.
  • The helper's stop listener ends with the helper process.
  • live/scheduler.rs, live/watcher.rs and cooperative.rs each end with their consumer.

The plan doc records the reasoning for each.

Verification (Windows 11)

make fmt CHECK=1, make lint and make test all pass: 541 Rust tests with every coverage floor met, plus the Python script test and 117 TypeScript tests.

@MelbourneDeveloper
MelbourneDeveloper merged commit fb63f4b into main Nov 18, 2026
10 checks passed
@MelbourneDeveloper
MelbourneDeveloper deleted the fix/owned-handles-0.7 branch November 18, 2026 12:20
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.

1 participant