On Mon, 1 Sept 2025 at 07:11, Akihiko Odaki <od...@rsg.ci.i.u-tokyo.ac.jp> wrote: > > Supersedes: > https://lore.kernel.org/qemu-devel/20250828-san-v9-0-c0dff4b8a...@rsg.ci.i.u-tokyo.ac.jp/ > ("[PATCH v9 0/2] Fix check-qtest-ppc64 sanitizer errors") > > MemoryRegions used to "piggyback" on their owners instead of using their > reference counters due to the circular dependencies between them, which > caused memory leak. > > I tried to fix it with "[PATCH v9 0/2] Fix check-qtest-ppc64 sanitizer > errors" but it resulted in a lengthy discussion; ultimately it is > attributed to the fact that "piggybacking" is hard to understand and > forces us design trade-offs. It was also insufficient because it only > deals with the container-subregion pattern and did not deal with DMA.
Unlike Peter Xu's proposed patch and your v9 patch you reference above, with this series I still see leaks doing a 'make check' on an ASAN build of the Arm targets. Here's a sample leak detected during the device-introspect-test: ==3769612==ERROR: LeakSanitizer: detected memory leaks Too many leaks! Only the first 5000 leaks encountered will be reported. Direct leak of 120 byte(s) in 8 object(s) allocated from: #0 0x61e094196de3 in malloc (/mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/qemu-system-arm+0x21f2de3) (BuildId: 9b33a0e2d440e084929ae6a2821eacb977772688) #1 0x79c9d0e06b09 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x62b09) (BuildId: 1eb6131419edb83b2178b682829a6913cf682d75) #2 0x79c9d0e1c4d8 in g_strdup (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x784d8) (BuildId: 1eb6131419edb83b2178b682829a6913cf682d75) #3 0x61e0958b6749 in g_strdup_inline /usr/include/glib-2.0/glib/gstrfuncs.h:321:10 #4 0x61e0958b6749 in memory_region_do_init /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../system/memory.c:1224:16 #5 0x61e0958b6551 in memory_region_init /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../system/memory.c:1250:5 #6 0x61e0958bc097 in memory_region_init_io /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../system/memory.c:1568:5 #7 0x61e09494b6d0 in stm32l4x5_gpio_init /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../hw/gpio/stm32l4x5_gpio.c:402:5 #8 0x61e096a36371 in object_init_with_type /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:428:9 #9 0x61e096a1d8db in object_initialize_with_type /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:570:5 #10 0x61e096a1d220 in object_initialize /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:578:5 #11 0x61e096a1dbdc in object_initialize_child_with_propsv /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:608:5 #12 0x61e096a1dab7 in object_initialize_child_with_props /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:591:10 #13 0x61e096a1e607 in object_initialize_child_internal /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:645:5 #14 0x61e0962c7f9a in stm32l4x5_soc_initfn /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../hw/arm/stm32l4x5_soc.c:150:9 #15 0x61e096a36371 in object_init_with_type /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:428:9 #16 0x61e096a36242 in object_init_with_type /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:424:9 #17 0x61e096a1d8db in object_initialize_with_type /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:570:5 #18 0x61e096a1f1fd in object_new_with_type /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:774:5 #19 0x61e096a1efc9 in object_new_with_class /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:782:12 #20 0x61e09709cec5 in qmp_device_list_properties /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/qom-qmp-cmds.c:206:11 #21 0x61e09594492c in qdev_device_help /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../system/qdev-monitor.c:313:17 #22 0x61e09594ac2c in hmp_device_add /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../system/qdev-monitor.c:989:9 #23 0x61e095b17b2d in handle_hmp_command_exec /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../monitor/hmp.c:1106:9 #24 0x61e095b12035 in handle_hmp_command /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../monitor/hmp.c:1158:9 #25 0x61e095b2549d in qmp_human_monitor_command /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../monitor/qmp-cmds.c:179:5 #26 0x61e09720c44a in qmp_marshal_human_monitor_command /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/qapi/qapi-commands-misc.c:347:14 #27 0x61e0973140f1 in do_qmp_dispatch_bh /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qapi/qmp-dispatch.c:128:5 #28 0x61e0973f01ad in aio_bh_call /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../util/async.c:172:5 #29 0x61e0973f0ee6 in aio_bh_poll /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../util/async.c:219:13 #30 0x61e09735c8b8 in aio_dispatch /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../util/aio-posix.c:436:5 (there are many more after this one) thanks -- PMM