Skip to content

fix(priority): release popped element references - #90

Open
dajiaohuang wants to merge 1 commit into
adrianbrad:mainfrom
dajiaohuang:bugfix/592-priority-release-references
Open

dajiaohuang wants to merge 1 commit into
adrianbrad:mainfrom
dajiaohuang:bugfix/592-priority-release-references

Conversation

@dajiaohuang

@dajiaohuang dajiaohuang commented Oct 22, 2026 •

Copy link
Copy Markdown

Summary

  • Zero the removed element's slot in priorityHeap.Pop before shortening the slice. Priority.Get, Clear, and Iterator use this path, so pointer-valued elements no longer remain reachable through the heap's unused backing-array slots.
  • Add deterministic internal backing-store regression tests for popped elements and existing reset/clear reference-release invariants.
  • Replace GC-finalizer-dependent retention tests with direct invariant checks and make ExampleBlocking output independent of scheduler timing.

Evidence

A synthetic pointer-element test against the original main implementation failed: after Priority.Get emptied a one-element queue, the backing slot still contained the returned pointer. It passes with the zeroing change.

Validation

  • go test -mod=mod -shuffle=on -timeout 60s -coverprofile=.task-tools/coverage.txt -covermode=atomic . — pass, 100.0% statements.
  • go test -mod=mod -shuffle=on -race -timeout 60s . — pass on Windows/amd64 (Go 1.26.3), using the task-local official llvm-mingw 20261020 UCRT x86_64 compiler.
  • go vet ./... — pass.
  • gofmt and git diff --check — pass.

The compiler was extracted only under the task-local tool directory; no global installation or configuration change. No real scheduler, service, or external queue was used.

@codecov

codecov Bot commented Oct 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (9f04dbf) to head (9e11b37).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #90   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            6         6           
  Lines          639       552   -87     
=========================================
- Hits           639       552   -87     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@adrianbrad

Copy link
Copy Markdown
Owner

Thanks, the Pop fix is right and matches what the Delay heap and Blocking.Get already do. I'd like to merge it, but please narrow the PR to that change:

  1. Keep the priority.go change. Add a blank line between var zero T and h.elems[n-1] = zero (wsl), the same as delay.go.
  2. Restore the finalizer tests in blocking_test.go, circular_test.go and priority_test.go, and the original ExampleBlocking. They pass in CI and they test what users care about, which is that the element can be collected, rather than private fields. If they're flaky on Windows, please open an issue with the failure output and I'll handle it separately.
  3. Add the regression test to priority_test.go as testPriorityGetReleasesReference, following testBlockingGetReleasesReference, and remove the three *_memory_test.go files.
  4. Rebase on main. The other 6 lint errors (marshal-receiver, gofumpt) were already on main and are fixed by ci(lint): pin golangci-lint and fix issues from v2.15.0 #91. You'll get a small conflict in priorityHeap.Pop; keep your version. Then run make lint and make test-coverage.

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