[#114774] [Ruby master Feature#19884] Make Safe Navigation Operator work on classes — "p8 (Petrik de Heus) via ruby-core" <ruby-core@...>
Issue #19884 has been reported by p8 (Petrik de Heus).
13 messages
2023/09/15
[ruby-core:114681] [Ruby master Bug#19873] Thread#native_thread_id is incorrectly cached across fork on Linux
From:
"kjtsanaktsidis (KJ Tsanaktsidis) via ruby-core" <ruby-core@...>
Date:
2023-09-12 03:58:44 UTC
List:
ruby-core #114681
Issue #19873 has been reported by kjtsanaktsidis (KJ Tsanaktsidis).
----------------------------------------
Bug #19873: Thread#native_thread_id is incorrectly cached across fork on Linux
https://bugs.ruby-lang.org/issues/19873
* Author: kjtsanaktsidis (KJ Tsanaktsidis)
* Status: Open
* Priority: Normal
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
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.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/