qemu-e2k/tcg
Emilio Cota 1ff4a81bd3 tcg: use QTree instead of GTree
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);
}
```

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/285
Reported-by: Valentin David <me@valentindavid.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Emilio Cota <cota@braap.org>
Message-Id: <20230205163758.416992-3-cota@braap.org>
[rth: Add QEMU_DISABLE_CFI for all callback using functions.]
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2023-03-28 15:23:10 -07:00
..
aarch64 tcg/aarch64: Fix patching of LDR in tb_target_set_jmp_target 2023-02-04 06:19:43 -10:00
arm tcg: Add TCG_TARGET_CALL_{RET,ARG}_I128 2023-02-04 06:19:42 -10:00
i386 tcg: Drop tcg_const_*_vec 2023-03-13 07:03:39 -07:00
loongarch64 tcg: Add TCG_TARGET_CALL_{RET,ARG}_I128 2023-02-04 06:19:42 -10:00
mips tcg: Add TCG_TARGET_CALL_{RET,ARG}_I128 2023-02-04 06:19:42 -10:00
ppc tcg: Add TCG_TARGET_CALL_{RET,ARG}_I128 2023-02-04 06:19:42 -10:00
riscv tcg: Add TCG_TARGET_CALL_{RET,ARG}_I128 2023-02-04 06:19:42 -10:00
s390x tcg: Add TCG_TARGET_CALL_{RET,ARG}_I128 2023-02-04 06:19:42 -10:00
sparc64 tcg: Add TCG_TARGET_CALL_{RET,ARG}_I128 2023-02-04 06:19:42 -10:00
tci tcg/tci: Add TCG_TARGET_CALL_{RET,ARG}_I128 2023-02-04 06:19:42 -10:00
meson.build
optimize.c tcg: Rename TEMP_LOCAL to TEMP_TB 2023-03-01 07:33:27 -10:00
region.c tcg: use QTree instead of GTree 2023-03-28 15:23:10 -07:00
tcg-common.c tcg: Silent -Wmissing-field-initializers warning 2023-02-27 22:29:01 +01:00
tcg-internal.h tcg: Add basic data movement for TCGv_i128 2023-02-04 06:19:42 -10:00
tcg-ldst.c.inc
tcg-op-gvec.c tcg: Create tcg/tcg-temp-internal.h 2023-03-13 06:42:05 -07:00
tcg-op-vec.c tcg: Drop tcg_const_*_vec 2023-03-13 07:03:39 -07:00
tcg-op.c tcg: Drop plugin_gen_disable_mem_helpers from tcg_gen_exit_tb 2023-03-22 15:06:57 +00:00
tcg-pool.c.inc
tcg.c tcg: Drop tcg_const_* 2023-03-13 07:03:39 -07:00
tci.c Don't include headers already included by qemu/osdep.h 2023-02-08 07:28:05 +01:00