qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [Bug 1813398] Re: qemu user calls malloc after fork in mult


From: Szabolcs Nagy
Subject: [Qemu-devel] [Bug 1813398] Re: qemu user calls malloc after fork in multi-threaded process
Date: Sat, 26 Jan 2019 13:57:58 -0000

** Also affects: qemu
   Importance: Undecided
       Status: New

** No longer affects: qemu (Ubuntu)

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1813398

Title:
  qemu user calls malloc after fork in multi-threaded process

Status in QEMU:
  New

Bug description:
  qemu user may hang in malloc on a musl based system because
  it calls malloc after fork (in a pthread_atfork handler)
  in the child process.

  this is undefined behaviour since the parent process is
  multi-threaded and only as-safe functions may be called
  in the child then. (if malloc/free is called concurrently
  with fork the malloc state will be corrupted in the child,
  it works on glibc because glibc takes the malloc locks
  before the fork syscall, but that breaks the as-safety of
  fork and thus non-conforming to posix)

  discussed at
  https://www.openwall.com/lists/musl/2019/01/26/1

  the bug is hard to reproduce (requires the call_rcu thread
  to call free concurrently with do_fork in the main thread),
  this one is observed with qemu-arm 3.1.0 running on x86_64
  executing an arm busybox sh:

  (gdb) bt
  #0  malloc (n=<optimized out>, address@hidden) at src/malloc/malloc.c:306
  #1  0x0000000060184ad3 in g_malloc (address@hidden) at gmem.c:99
  #2  0x000000006018bcab in g_strdup (str=<optimized out>, address@hidden 
"call_rcu") at gstrfuncs.c:363
  #3  0x000000006016e31d in qemu_thread_create (address@hidden, address@hidden 
"call_rcu", 
      address@hidden <call_rcu_thread>, address@hidden, address@hidden)
      at /home/pmos/build/src/qemu-3.1.0/util/qemu-thread-posix.c:526
  #4  0x0000000060174b99 in rcu_init_complete () at 
/home/pmos/build/src/qemu-3.1.0/util/rcu.c:327
  #5  0x00000000601c4fac in __fork_handler (who=1) at 
src/thread/pthread_atfork.c:26
  #6  0x00000000601be8db in fork () at src/process/fork.c:33
  #7  0x000000006009d191 in do_fork (env=0x627aaed0, address@hidden, 
address@hidden, address@hidden, 
      address@hidden, address@hidden) at 
/home/pmos/build/src/qemu-3.1.0/linux-user/syscall.c:5528
  #8  0x00000000600af894 in do_syscall1 (address@hidden, address@hidden, 
address@hidden, address@hidden, 
      arg3=<optimized out>, arg4=8, arg5=1015744, arg6=-74144, arg7=0, arg8=0) 
at /home/pmos/build/src/qemu-3.1.0/linux-user/syscall.c:7042
  #9  0x00000000600a835c in do_syscall (address@hidden, num=2, arg1=0, 
arg2=-8700192, arg3=<optimized out>, 
      arg4=<optimized out>, arg5=1015744, arg6=-74144, arg7=0, arg8=0) at 
/home/pmos/build/src/qemu-3.1.0/linux-user/syscall.c:11533
  #10 0x00000000600c265f in cpu_loop (address@hidden) at 
/home/pmos/build/src/qemu-3.1.0/linux-user/arm/cpu_loop.c:360
  #11 0x00000000600417a2 in main (argc=<optimized out>, argv=0x7ffe367d57b8, 
envp=<optimized out>)
      at /home/pmos/build/src/qemu-3.1.0/linux-user/main.c:819

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1813398/+subscriptions



reply via email to

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