qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 1/2] util/log: Derive thread id from getpid() on hosts w/o


From: Paolo Bonzini
Subject: Re: [PATCH v2 1/2] util/log: Derive thread id from getpid() on hosts w/o gettid() syscall
Date: Thu, 20 Oct 2022 12:39:41 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1

On 10/19/22 17:57, Daniel P. Berrangé wrote:
+    if (my_id == -1) {
+        my_id = getpid() + qatomic_fetch_inc(&counter);
+    }
+    return my_id;
This doesn't look safe for linux-user when we fork, but don't exec.

Linux-user won't ever get here, however bsd-user might. We should have get_thread_id() somewhere in util/, for example

https://github.com/wine-mirror/wine/blob/master/dlls/ntdll/unix/server.c

The getpid() will change after the fork, but counter won't be
reset, so a thread in the parent could clash with a thread
in the forked child.

It might clash even if the counter is reset for that matter.

Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]