qemu-e2k/monitor
Kevin Wolf 357bda9590 monitor: Fix order in monitor_cleanup()
We can only destroy Monitor objects after we're sure that they are not
in use by the dispatcher coroutine any more. This fixes crashes like the
following where we tried to destroy a monitor mutex while the dispatcher
coroutine still holds it:

 (gdb) bt
 #0  0x00007fe541cf4bc5 in raise () at /lib64/libc.so.6
 #1  0x00007fe541cdd8a4 in abort () at /lib64/libc.so.6
 #2  0x000055c24e965327 in error_exit (err=16, msg=0x55c24eead3a0 <__func__.33> "qemu_mutex_destroy") at ../util/qemu-thread-posix.c:37
 #3  0x000055c24e9654c3 in qemu_mutex_destroy (mutex=0x55c25133e0f0) at ../util/qemu-thread-posix.c:70
 #4  0x000055c24e7cfaf1 in monitor_data_destroy_qmp (mon=0x55c25133dfd0) at ../monitor/qmp.c:439
 #5  0x000055c24e7d23bc in monitor_data_destroy (mon=0x55c25133dfd0) at ../monitor/monitor.c:615
 #6  0x000055c24e7d253a in monitor_cleanup () at ../monitor/monitor.c:644
 #7  0x000055c24e6cb002 in qemu_cleanup () at ../softmmu/vl.c:4549
 #8  0x000055c24e0d259b in main (argc=24, argv=0x7ffff66b0d58, envp=0x7ffff66b0e20) at ../softmmu/main.c:51

Reported-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20201013125027.41003-1-kwolf@redhat.com>
Tested-by: Ben Widawsky <ben.widawsky@intel.com>
Tested-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2020-10-15 16:06:28 +02:00
..
hmp-cmds.c monitor: Add Monitor parameter to monitor_get_cpu_index() 2020-10-09 07:08:19 +02:00
hmp.c hmp: Add support for coroutine command handlers 2020-10-09 07:08:20 +02:00
meson.build configure: do not include dependency flags in QEMU_CFLAGS and LIBS 2020-09-08 11:43:16 +02:00
misc.c hmp: Update current monitor only in handle_hmp_command() 2020-10-09 07:08:19 +02:00
monitor-internal.h hmp: Add support for coroutine command handlers 2020-10-09 07:08:20 +02:00
monitor.c monitor: Fix order in monitor_cleanup() 2020-10-15 16:06:28 +02:00
qmp-cmds-control.c monitor: Use getter/setter functions for cur_mon 2020-10-09 07:08:19 +02:00
qmp-cmds.c monitor: Use getter/setter functions for cur_mon 2020-10-09 07:08:19 +02:00
qmp.c qmp: Move dispatcher to a coroutine 2020-10-09 07:08:20 +02:00
trace-events monitor: Split out monitor/monitor.c 2019-06-18 08:14:17 +02:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00