Bug #17505

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

Added by marcandre (Marc-Andre Lafortune) 2 months ago. Updated 23 days ago.

Target version:


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) 25 days ago

I've added a pull request that fixes the documentation and removes code that deals with a missing thread group:


Updated by jeremyevans (Jeremy Evans) 24 days 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) 23 days 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 env ALL_RUBY_SINCE=ruby-1.8 ./all-ruby -e 'th=Thread.start{};Thread.pass;p'
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) 23 days ago

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

Also available in: Atom PDF