Skip to contentSkip to conversation

Some memory leak fixes

PATCH Superseded Marc-André Lureau 6 participants 15 messages Nov 7, 2019 – Nov 20, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Some memory leak fixes

Hi,

Another bunch of fixes spotted by ASAN when running check-qtest-x86_64.

Marc-André Lureau (3):
virtio-input: fix memory leak on unrealize
qtest: fix qtest_qmp_device_add leak
cpu-plug-test: fix leaks

 hw/input/virtio-input.c | 3 +++
 tests/cpu-plug-test.c   | 2 ++
 tests/libqtest.c        | 1 +
 3 files changed, 6 insertions(+)
Signature · 1 line
2.24.0.rc0.20.gd81542e6f3
#1 lore raw

PATCH 1/3 virtio-input: fix memory leak on unrealize

Spotted by ASAN + minor stylistic change.

---
 hw/input/virtio-input.c | 3 +++
 1 file changed, 3 insertions(+)
hw/input/virtio-input.c +3 -0
index 51617a5885..ec54e46ad6 100644
@@ -275,6 +275,7 @@ static void virtio_input_finalize(Object *obj)
 
     g_free(vinput->queue);
 }
+
 static void virtio_input_device_unrealize(DeviceState *dev, Error **errp)
 {
     VirtIOInputClass *vic = VIRTIO_INPUT_GET_CLASS(dev);
@@ -288,6 +289,8 @@ static void virtio_input_device_unrealize(DeviceState *dev, Error **errp)
             return;
         }
     }
+    virtio_del_queue(vdev, 0);
+    virtio_del_queue(vdev, 1);
     virtio_cleanup(vdev);
 }
 
Signature · 1 line
2.24.0.rc0.20.gd81542e6f3
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] virtio-input: fix memory leak on unrealize

Quoted 3 lines · Marc-André Lureau

Spotted by ASAN + minor stylistic change.

Quoted 27 lines
---
 hw/input/virtio-input.c | 3 +++
 1 file changed, 3 insertions(+)
hw/input/virtio-input.c +3 -0
index 51617a5885..ec54e46ad6 100644
@@ -275,6 +275,7 @@ static void virtio_input_finalize(Object *obj)
 
     g_free(vinput->queue);
 }
+
 static void virtio_input_device_unrealize(DeviceState *dev, Error **errp)
 {
     VirtIOInputClass *vic = VIRTIO_INPUT_GET_CLASS(dev);
@@ -288,6 +289,8 @@ static void virtio_input_device_unrealize(DeviceState *dev, Error **errp)
             return;
         }
     }
+    virtio_del_queue(vdev, 0);
+    virtio_del_queue(vdev, 1);
     virtio_cleanup(vdev);
 }
 
Signature · 1 line
2.24.0.rc0.20.gd81542e6f3
#3 lore raw

PATCH 2/3 qtest: fix qtest_qmp_device_add leak

In reply to Marc-André Lureau

Spotted by ASAN.

---
 tests/libqtest.c | 1 +
 1 file changed, 1 insertion(+)
tests/libqtest.c +1 -0
index 3706bccd8d..91e9cb220c 100644
@@ -1274,6 +1274,7 @@ void qtest_qmp_device_add(QTestState *qts, const char *driver, const char *id,
     qdict_put_str(args, "id", id);
 
     qtest_qmp_device_add_qdict(qts, driver, args);
+    qobject_unref(args);
 }
 
 static void device_deleted_cb(void *opaque, const char *name, QDict *data)
Signature · 1 line
2.24.0.rc0.20.gd81542e6f3
#4 lore raw

Re: [PATCH 2/3] qtest: fix qtest_qmp_device_add leak

Quoted 13 lines · Marc-André Lureau

Spotted by ASAN.

---
 tests/libqtest.c | 1 +
 1 file changed, 1 insertion(+)
tests/libqtest.c +0 -0
index 3706bccd8d..91e9cb220c 100644

tests/libqtest.c void qtest_qmp_device_add(QTestState *qts, const char *driver, const char *id, · line 1280

Quoted 7 lines
tests/libqtest.c +1 -0
@@ -1274,6 +1274,7 @@ void qtest_qmp_device_add(QTestState *qts, const char *driver, const char *id,
     qdict_put_str(args, "id", id);
 
     qtest_qmp_device_add_qdict(qts, driver, args);
+    qobject_unref(args);
 }
 
 static void device_deleted_cb(void *opaque, const char *name, QDict *data)

Stupid question: where is the qobject_ref()?

Thanks,
Laurent

#5 lore raw

Re: [PATCH 2/3] qtest: fix qtest_qmp_device_add leak

Hi

Quoted 16 lines · Laurent Vivier
Quoted 14 lines · Marc-André Lureau

Spotted by ASAN.

---
 tests/libqtest.c | 1 +
 1 file changed, 1 insertion(+)
tests/libqtest.c +0 -0
index 3706bccd8d..91e9cb220c 100644
@@ -1274,6 +1274,7 @@ void qtest_qmp_device_add(QTestState *qts, const char *driver, const char *id,
     qdict_put_str(args, "id", id);
 
Quoted 8 lines

tests/libqtest.c void qtest_qmp_device_add(QTestState *qts, const char *driver, const char *id, · line 1280

Quoted 6 lines
tests/libqtest.c +1 -0
     qtest_qmp_device_add_qdict(qts, driver, args);
+    qobject_unref(args);
 }
 
 static void device_deleted_cb(void *opaque, const char *name, QDict *data)

Stupid question: where is the qobject_ref()?

The initial ref is from qobject_from_vjsonf_nofail() constructor

Signature · 1 line
Marc-André Lureau
Reviewed-by on v1 2/3
#6 lore raw

Re: [PATCH 2/3] qtest: fix qtest_qmp_device_add leak

In reply to Marc-André Lureau
Quoted 13 lines · Marc-André Lureau

Spotted by ASAN.

---
  tests/libqtest.c | 1 +
  1 file changed, 1 insertion(+)
tests/libqtest.c +0 -0
index 3706bccd8d..91e9cb220c 100644

tests/libqtest.c void qtest_qmp_device_add(QTestState *qts, const char *driver, const char *id, · line 1280

Quoted 7 lines
tests/libqtest.c +1 -0
@@ -1274,6 +1274,7 @@ void qtest_qmp_device_add(QTestState *qts, const char *driver, const char *id,
      qdict_put_str(args, "id", id);
 
      qtest_qmp_device_add_qdict(qts, driver, args);
+    qobject_unref(args);
  }
 
  static void device_deleted_cb(void *opaque, const char *name, QDict *data)
Fixes b4510bb4109f5f ("tests: add qtest_qmp_device_add_qdict() helper")

I can queue this via the qtest tree if nobody else wants to take it.

#7 lore raw

PATCH 3/3 cpu-plug-test: fix leaks

In reply to Marc-André Lureau

Spotted by ASAN.

---
 tests/cpu-plug-test.c | 2 ++
 1 file changed, 2 insertions(+)
tests/cpu-plug-test.c +2 -0
index 058cef5ac1..30e514bbfb 100644
@@ -99,6 +99,7 @@ static void test_plug_with_device_add(gconstpointer data)
 
         cpu = qobject_to(QDict, e);
         if (qdict_haskey(cpu, "qom-path")) {
+            qobject_unref(e);
             continue;
         }
 
@@ -107,6 +108,7 @@ static void test_plug_with_device_add(gconstpointer data)
 
         qtest_qmp_device_add_qdict(qts, td->device_model, props);
         hotplugged++;
+        qobject_unref(e);
     }
 
     /* make sure that there were hotplugged CPUs */
Signature · 1 line
2.24.0.rc0.20.gd81542e6f3
Reviewed-by on v1 3/3
#8 lore raw

Re: [PATCH 3/3] cpu-plug-test: fix leaks

Quoted 21 lines · Marc-André Lureau

Spotted by ASAN.

---
  tests/cpu-plug-test.c | 2 ++
  1 file changed, 2 insertions(+)
tests/cpu-plug-test.c +1 -0
index 058cef5ac1..30e514bbfb 100644
@@ -99,6 +99,7 @@ static void test_plug_with_device_add(gconstpointer data)
 
          cpu = qobject_to(QDict, e);
          if (qdict_haskey(cpu, "qom-path")) {
+            qobject_unref(e);
              continue;
          }
 

tests/cpu-plug-test.c static void test_plug_with_device_add(gconstpointer data) · line 114

Quoted 7 lines
tests/cpu-plug-test.c +1 -0
@@ -107,6 +108,7 @@ static void test_plug_with_device_add(gconstpointer data)
 
          qtest_qmp_device_add_qdict(qts, td->device_model, props);
          hotplugged++;
+        qobject_unref(e);
      }
 
      /* make sure that there were hotplugged CPUs */
Fixes 021a007efc3 ("cpu-plug-test: fix device_add for pc/q35 machines")
#9 lore raw
In reply to Marc-André Lureau
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series failed the docker-quick@centos7 build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1 === TEST SCRIPT END ===

TEST check-unit: tests/test-thread-pool
TEST check-unit: tests/test-hbitmap
**
ERROR:/tmp/qemu-test/src/tests/migration-test.c:903:wait_for_migration_fail: assertion failed: (!strcmp(status, "setup") || !strcmp(status, "failed") || (allow_active && !strcmp(status, "active")))
ERROR - Bail out! ERROR:/tmp/qemu-test/src/tests/migration-test.c:903:wait_for_migration_fail: assertion failed: (!strcmp(status, "setup") || !strcmp(status, "failed") || (allow_active && !strcmp(status, "active")))
make: *** [check-qtest-aarch64] Error 1
make: *** Waiting for unfinished jobs....
TEST iotest-qcow2: 013
TEST check-unit: tests/test-bdrv-drain
---
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=7099ba6365db4fc0b071e2fac87b5c55', '-u', '1003', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=1', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-softdboz/src/docker-src.2019-11-07-16.44.12.4395:/var/tmp/qemu:z,ro', 'qemu:centos7', '/var/tmp/qemu/run', 'test-quick']' returned non-zero exit status 2. filter=--filter=label=com.qemu.instance.uuid=7099ba6365db4fc0b071e2fac87b5c55
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-softdboz/src'
make: *** [docker-run-test-quick@centos7] Error 2

real 13m27.012s
user 0m8.295s

The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]

#10 lore raw
Quoted 14 lines · On 07/11/2019 22.57, [email protected] wrote:

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series failed the docker-quick@centos7 build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1 === TEST SCRIPT END ===

Quoted 5 lines

TEST check-unit: tests/test-thread-pool
TEST check-unit: tests/test-hbitmap
**
ERROR:/tmp/qemu-test/src/tests/migration-test.c:903:wait_for_migration_fail: assertion failed: (!strcmp(status, "setup") || !strcmp(status, "failed") || (allow_active && !strcmp(status, "active"))) ERROR - Bail out! ERROR:/tmp/qemu-test/src/tests/migration-test.c:903:wait_for_migration_fail: assertion failed: (!strcmp(status, "setup") || !strcmp(status, "failed") || (allow_active && !strcmp(status, "active")))

I assume this is unrelated to your patches and a generic Patchew problem instead?

Thomas

#11 lore raw
Quoted 30 lines · Thomas Huth
Quoted 18 lines · On 07/11/2019 22.57, [email protected] wrote:

Patchew URL:
https://patchew.org/QEMU/[email protected]/

Hi,

This series failed the docker-quick@centos7 build test. Please find the testing commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1 === TEST SCRIPT END ===

Quoted 10 lines

   TEST    check-unit: tests/test-thread-pool
   TEST    check-unit: tests/test-hbitmap
** ERROR:/tmp/qemu-test/src/tests/migration-test.c:903:wait_for_migration_fail:
assertion failed: (!strcmp(status, "setup") || !strcmp(status, "failed") || (allow_active && !strcmp(status, "active")))
ERROR - Bail out! ERROR:/tmp/qemu-test/src/tests/migration-test.c:903:wait_for_migration_fail:
assertion failed: (!strcmp(status, "setup") || !strcmp(status, "failed") || (allow_active && !strcmp(status, "active")))

Quoted 2 lines

I assume this is unrelated to your patches and a generic Patchew problem instead?

Unrelated to patchew too, but the problem has already been reported. I think dgilbert is looking at this.

Thanks,

#12 lore raw
In reply to Marc-André Lureau
Quoted 3 lines · Marc-André Lureau

Hi,

Another bunch of fixes spotted by ASAN when running check-qtest-x86_64.

So who's merging this?

Quoted 12 lines

Marc-André Lureau (3):
virtio-input: fix memory leak on unrealize
qtest: fix qtest_qmp_device_add leak
cpu-plug-test: fix leaks

 hw/input/virtio-input.c | 3 +++
 tests/cpu-plug-test.c   | 2 ++
 tests/libqtest.c        | 1 +
 3 files changed, 6 insertions(+)
Signature · 1 line
2.24.0.rc0.20.gd81542e6f3
#13 lore raw

Hi

Quoted 10 lines · Michael S. Tsirkin
Quoted 3 lines · Marc-André Lureau

Hi,

Another bunch of fixes spotted by ASAN when running check-qtest-x86_64.

So who's merging this?

Quoted 2 lines

Marc-André Lureau (3):
virtio-input: fix memory leak on unrealize

This one is still pending. Michael, could you take it?

Quoted 11 lines
Quoted 10 lines

qtest: fix qtest_qmp_device_add leak
cpu-plug-test: fix leaks

 hw/input/virtio-input.c | 3 +++
 tests/cpu-plug-test.c   | 2 ++
 tests/libqtest.c        | 1 +
 3 files changed, 6 insertions(+)

--
2.24.0.rc0.20.gd81542e6f3

Signature · 1 line
Marc-André Lureau
#14 lore raw
Quoted 7 lines · Marc-André Lureau

Hi

Quoted 4 lines · Michael S. Tsirkin
Quoted 2 lines · Marc-André Lureau

Hi,

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Another bunch of fixes spotted by ASAN when running check-qtest-x86_64.

So who's merging this?

Quoted 2 lines

Marc-André Lureau (3):
virtio-input: fix memory leak on unrealize

This one is still pending. Michael, could you take it?

Expected gerd to do that but ok. Pls re-post a separate patch though, I don't cherry-pick things out of series.

Quoted 15 lines
Quoted 11 lines
Quoted 10 lines

qtest: fix qtest_qmp_device_add leak
cpu-plug-test: fix leaks

 hw/input/virtio-input.c | 3 +++
 tests/cpu-plug-test.c   | 2 ++
 tests/libqtest.c        | 1 +
 3 files changed, 6 insertions(+)

--
2.24.0.rc0.20.gd81542e6f3

Signature · 1 line
Marc-André Lureau