qemu-patch-raspberry4/include/sysemu
Marc-André Lureau aa5cb7f5e8 char: do not use atexit cleanup handler
It turns out qemu is calling exit() in various places from various
threads without taking much care of resources state. The atexit()
cleanup handlers cannot easily destroy resources that are in use (by
the same thread or other).

Since c1111a24a3, TCG arm guests run into the following abort() when
running tests, the chardev mutex is locked during the write, so
qemu_mutex_destroy() returns an error:

 #0  0x00007fffdbb806f5 in raise () at /lib64/libc.so.6
 #1  0x00007fffdbb822fa in abort () at /lib64/libc.so.6
 #2  0x00005555557616fe in error_exit (err=<optimized out>, msg=msg@entry=0x555555c38c30 <__func__.14622> "qemu_mutex_destroy")
     at /home/drjones/code/qemu/util/qemu-thread-posix.c:39
 #3  0x0000555555b0be20 in qemu_mutex_destroy (mutex=mutex@entry=0x5555566aa0e0) at /home/drjones/code/qemu/util/qemu-thread-posix.c:57
 #4  0x00005555558aab00 in qemu_chr_free_common (chr=0x5555566aa0e0) at /home/drjones/code/qemu/qemu-char.c:4029
 #5  0x00005555558b05f9 in qemu_chr_delete (chr=<optimized out>) at /home/drjones/code/qemu/qemu-char.c:4038
 #6  0x00005555558b05f9 in qemu_chr_delete (chr=<optimized out>) at /home/drjones/code/qemu/qemu-char.c:4044
 #7  0x00005555558b062c in qemu_chr_cleanup () at /home/drjones/code/qemu/qemu-char.c:4557
 #8  0x00007fffdbb851e8 in __run_exit_handlers () at /lib64/libc.so.6
 #9  0x00007fffdbb85235 in  () at /lib64/libc.so.6
 #10 0x00005555558d1b39 in testdev_write (testdev=0x5555566aa0a0) at /home/drjones/code/qemu/backends/testdev.c:71
 #11 0x00005555558d1b39 in testdev_write (chr=<optimized out>, buf=0x7fffc343fd9a "", len=0) at /home/drjones/code/qemu/backends/testdev.c:95
 #12 0x00005555558adced in qemu_chr_fe_write (s=0x5555566aa0e0, buf=buf@entry=0x7fffc343fd98 "0q", len=len@entry=2) at /home/drjones/code/qemu/qemu-char.c:282

Instead of using a atexit() handler, only run the chardev cleanup as
initially proposed at the end of main(), where there are less chances
(hic) of conflicts or other races.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reported-by: Andrew Jones <drjones@redhat.com>
Message-Id: <20160704153823.16879-1-marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-07-13 13:30:00 +02:00
..
accel.h accel: make configure_accelerator return void 2016-05-18 15:04:27 +03:00
arch_init.h cpu: Eliminate cpudef_init(), cpudef_setup() 2016-05-23 19:47:37 -03:00
balloon.h Inhibit ballooning during postcopy 2015-11-10 15:00:28 +01:00
block-backend.h block: Convert bdrv_pwrite_zeroes() to BdrvChild 2016-07-05 16:46:27 +02:00
blockdev.h include: Clean up includes 2016-02-23 12:43:05 +00:00
bt.h sysemu: avoid proliferation of include/ subdirectories 2013-04-15 18:19:25 +02:00
char.h char: do not use atexit cleanup handler 2016-07-13 13:30:00 +02:00
cpus.h include: move CPU-related definitions out of qemu-common.h 2016-05-19 13:08:04 +02:00
device_tree.h device_tree: qemu_fdt_getprop_cell converted to use the error API 2016-02-19 09:42:30 -07:00
dma.h dma-helpers: change BlockBackend to opaque value in DMAIOFunc 2016-05-25 19:04:11 +02:00
dump-arch.h dump: allow target to set the physical base 2016-01-15 14:40:25 +00:00
dump.h DumpState: adding total_size and written_size fields 2016-02-22 18:40:28 +01:00
hostmem.h remove comment for nonexistent structure member 2016-05-18 15:04:26 +03:00
iothread.h Remove various unused functions 2015-05-08 14:11:10 +03:00
kvm.h kvm: API to obtain max supported mem slots 2016-06-07 10:17:45 +10:00
kvm_int.h kvm-all: add support for multiple address spaces 2015-07-06 17:59:43 +02:00
memory_mapping.h Use scripts/clean-includes to drop redundant qemu/typedefs.h 2016-03-22 22:20:16 +01:00
numa.h include: Clean up includes 2016-02-23 12:43:05 +00:00
os-posix.h os-posix: include sys/mman.h 2016-06-16 18:39:03 +02:00
os-win32.h osdep: remove use of socket_error() from all code 2016-03-10 17:19:34 +00:00
qtest.h include: Clean up includes 2016-02-23 12:43:05 +00:00
replay.h replay: introduce block devices record/replay 2016-03-30 12:15:57 +02:00
rng-random.h rng-random: rename RndRandom to RngRandom 2016-05-23 12:18:43 +05:30
rng.h rng: switch request queue to QSIMPLEQ 2016-03-08 12:54:14 +05:30
seccomp.h include: Clean up includes 2016-02-23 12:43:05 +00:00
sysemu.h hw/pci: delay bus_master_enable_region initialization 2016-07-04 14:50:01 +03:00
tpm.h TPM: fix build with tpm disabled 2015-06-03 18:19:15 +02:00
tpm_backend.h include: Clean up includes 2016-02-23 12:43:05 +00:00
tpm_backend_int.h all: Remove unnecessary glib.h includes 2016-06-07 18:19:24 +03:00
watchdog.h watchdog: introduction of get_watchdog_action 2016-01-27 15:34:47 +01:00
xen-mapcache.h include: Clean up includes 2016-02-23 12:43:05 +00:00