Project

General

Profile

Actions

Bug #17505

closed

Can `Thread#group` actually be `nil`?

Added by marcandre (Marc-Andre Lafortune) about 3 years ago. Updated about 3 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:101892]

Description

Is there a circumstance where Thread#group could actually be nil?

The documentation says so, there seems to be source code for this, but I can find no test or RubySpec for this and I don't see anywhere in the ThreadGroup API that could allow this.

Updated by jeremyevans0 (Jeremy Evans) about 3 years ago

I've added a pull request that fixes the documentation and removes code that deals with a missing thread group: https://github.com/ruby/ruby/pull/4163

Actions #2

Updated by jeremyevans (Jeremy Evans) about 3 years ago

  • Status changed from Open to Closed

Applied in changeset git|fc83b4896e9d7de084b203b133b84c1209c6ad88.


Don't document that Thread#group can return nil

Thread's are assigned a group at initialization, and no API exists
for them to unassign them from a group without assigning them to
another group.

Fixes [Bug #17505]

Updated by znz (Kazuhiro NISHIYAMA) about 3 years ago

Just FYI

Japanese documents says

死んでいるスレッドは nil を返します。

Dead thread's group returns nil from 1.8.0 to 1.9.0-0.

% docker run -it --rm ghcr.io/ruby/all-ruby env ALL_RUBY_SINCE=ruby-1.8 ./all-ruby -e 'th=Thread.start{};Thread.pass;p th.group.class'
ruby-1.8.0            NilClass
...
ruby-1.9.0-0          NilClass
ruby-1.9.0-1          ThreadGroup
...
ruby-3.0.0            ThreadGroup

Updated by marcandre (Marc-Andre Lafortune) about 3 years ago

Perfect, so this confirms the spec has changed a long time ago 👍

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0