Skip to content

Ensure thread is released on completion - #114

Open
awilfox wants to merge 1 commit into
ruby:masterfrom
awilfox:awilfox/release-thread-on-completion
Open

Ensure thread is released on completion#114
awilfox wants to merge 1 commit into
ruby:masterfrom
awilfox:awilfox/release-thread-on-completion

Conversation

@awilfox

@awilfox awilfox commented Aug 4, 2026

Copy link
Copy Markdown

This prevents leaking Fiber objects when running timeouts in nested threads.

Tests pass locally on Darwin arm64 (3.4), Linux ppc64 (3.4), and Windows x86_64 (4.0).

@OskarEichler

Copy link
Copy Markdown
Contributor

I verified this retention fix against the current 0.6.1 code and found one adjacent payload-retention path: after a request completes, the retained Request still holds its exception class and message. With a 1 MiB message, the existing consumer retained the payload in 10/10 runs on Ruby 4.0.6 and 3.2.11.

I prepared a one-line follow-up directly on this PR head: OskarEichler@67e0435

It clears @exception_class and @message under the same mutex alongside @thread. The focused payload model releases both fields in 20/20 runs on each Ruby; the combined suite passes 284 tests / 636 assertions with zero failures. No repository tests were changed. I kept this as a follow-up on #114 to preserve the original contribution and avoid a competing PR.

@eregon

eregon commented Aug 30, 2026

Copy link
Copy Markdown
Member

Sorry for late review.

This seems redundant and unnecessary, because the Request object will GC soon after finished is called, and the timeout thread has @queue.pop'd it, as then nothing will refer to it.
If there indeed an issue, please provide a reproduction.

This prevents leaking Fiber objects when running timeouts in nested threads.

How are Fibers involved here?
What do you mean by "nested threads"?

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.

3 participants