Skip to content

No close_notify from the finalizer - #89

Open
krynju wants to merge 1 commit into
JuliaWeb:mainfrom
krynju:kr/finalizer-no-shutdown
Open

krynju wants to merge 1 commit into
JuliaWeb:mainfrom
krynju:kr/finalizer-no-shutdown

Conversation

@krynju

@krynju krynju commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Split out of #73, as asked in the review there: an independent fix, against main.

Bug. The finalizer calls close(ssl), which sends the close_notify, a socket write. A write that has to wait for the socket switches tasks, which a finalizer may not do. On nightly, where the socket write path waits more readily, NoCloseStream printed "task switch not allowed from inside gc finalizer"; on released Julia it only waits when the socket buffer is full, so the hazard is latent.

Fix. The finalizer calls close(ssl, false): the SSL object is freed and the socket closed, nothing is written. A stream the user wants shut down cleanly still gets its close_notify from an explicit close(ssl).

No test: NoCloseStream is the existing coverage, and the failure depends on GC timing. No version bump; the fixes can be released together.

🤖 Generated with Claude Code

The finalizer called `close(ssl)`, which sends the close_notify, a
socket write. A write that has to wait for the socket switches tasks,
which a finalizer may not do: on nightly, where the socket write path
waits more readily, `NoCloseStream` printed "task switch not allowed
from inside gc finalizer". Older versions only wait when the socket
buffer is full, so the hazard was latent. The finalizer now calls
`close(ssl, false)`: the SSL object is freed and the socket closed,
nothing is written.

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

codecov Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.39%. Comparing base (10f7b7b) to head (149701f).
⚠️ Report is 41 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #89      +/-   ##
==========================================
- Coverage   77.56%   77.39%   -0.17%     
==========================================
  Files           2        2              
  Lines        1083     1190     +107     
==========================================
+ Hits          840      921      +81     
- Misses        243      269      +26     

☔ 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.

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