qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v2 2/2] tcg: use QTree instead of GTree


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH v2 2/2] tcg: use QTree instead of GTree
Date: Tue, 21 Mar 2023 17:23:49 +0100
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.9.0

On 5/2/23 17:37, Emilio Cota wrote:
qemu-user can hang in a multi-threaded fork. One common
reason is that when creating a TB, between fork and exec
we manipulate a GTree whose memory allocator (GSlice) is
not fork-safe.

Although POSIX does not mandate it, the system's allocator
(e.g. tcmalloc, libc malloc) is probably fork-safe.

Fix some of these hangs by using QTree, which uses the system's
allocator regardless of the Glib version that we used at
configuration time.

Tested with the test program in the original bug report, i.e.:
```

void garble() {
   int pid = fork();
   if (pid == 0) {
     exit(0);
   } else {
     int wstatus;
     waitpid(pid, &wstatus, 0);
   }
}

void supragarble(unsigned depth) {
   if (depth == 0)
     return ;

   std::thread a(supragarble, depth-1);
   std::thread b(supragarble, depth-1);
   garble();
   a.join();
   b.join();
}

int main() {
   supragarble(10);
}
```

Fixes: #285

Please use: 'Fixes: https://gitlab.com/qemu-project/qemu/-/issues/285'

Also,

Reported-by: Valentin David <me@valentindavid.com>


Signed-off-by: Emilio Cota <cota@braap.org>
---
  accel/tcg/tb-maint.c | 17 +++++++++--------
  tcg/region.c         | 19 ++++++++++---------
  2 files changed, 19 insertions(+), 17 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>




reply via email to

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