Skip to content

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

Merged
adrianbrad merged 3 commits into
adrianbrad:mainfrom
dajiaohuang:bugfix/592-priority-release-references
Nov 7, 2026
Merged

adrianbrad merged 3 commits into
adrianbrad:mainfrom
dajiaohuang:bugfix/592-priority-release-references

Conversation

@dajiaohuang

@dajiaohuang dajiaohuang commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Clear the popped element slot in priorityHeap.Pop so the backing array does not retain the removed reference.
  • Restore the existing finalizer tests and ExampleBlocking, and add a priority Get reference-release regression alongside those tests.
  • Rebase on current main as requested.

Validation

  • A non-race shuffled coverage run reported 100.0% statement coverage but failed because ExampleBlocking printed 2ms instead of 1ms on Windows. Reported separately in ExampleBlocking elapsed-time output varies on Windows #92 as requested.
  • make lint and make test-coverage were not run: make, golangci-lint, and a C compiler are unavailable on PATH. The earlier head's validation does not apply to this revision.

@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 (ab5bf8f) to head (0898838).

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #90   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            6         6           
  Lines          550       552    +2     
=========================================
+ Hits           550       552    +2     
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.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

@adrianbrad adrianbrad left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for the fix and the regression test. I pushed a small commit adding the blank lines wsl_v5 requires so Lint goes green.

One non-blocking note for a follow-up: the comment inside Priority.Reset still says Pop leaves references past the new length, which this PR now prevents, so it could be reworded.

@adrianbrad
adrianbrad merged commit 36e253a into adrianbrad:main Nov 7, 2026
9 checks passed
@adrianbrad adrianbrad mentioned this pull request Nov 7, 2026
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