Actions
Bug #19873
closedThread#native_thread_id is incorrectly cached across fork on Linux
Description
On Linux, when a process forks, the native thread ID of the (only) thread in the forked child should change.
>> libc = Fiddle.dlopen(nil)
=> #<Fiddle::Handle:0x0000ffffb0d8e900>
>> gettid = Fiddle::Function.new(libc['gettid'], [], Fiddle::TYPE_INT)
=>
#<Fiddle::Function:0x0000ffffb15d1130
...
>> gettid.call
=> 33
>> fork { puts gettid.call }; nil;
=> nil
36
However, the value of Thread#native_thread_id
is (incorrectly) still set to the old value.
>> Thread.current.native_thread_id
=> 33
>> fork { puts Thread.current.native_thread_id }; nil;
=> nil
33
I think #native_thread_id
should be re-fetched from the operating system via gettid(2)
after fork.
This patch should fix it I think? https://github.com/ruby/ruby/pull/8418
Updated by kjtsanaktsidis (KJ Tsanaktsidis) over 1 year ago
- Description updated (diff)
Updated by Anonymous over 1 year ago
- Status changed from Open to Closed
Applied in changeset git|0117a6d389c5b607eaec1b7f917132efa356f665.
Fix Thread#native_thread_id being cached across fork (#8418)
The native thread ID can and does change on some operating systems (e.g.
Linux) after forking, so it needs to be re-queried.
[Bug #19873]
Actions
Like0
Like0Like0