[PATCH 0/3] Some memory leak fixes

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH 0/3] Some memory leak fixes

Marc-André Lureau
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(+)

--
2.24.0.rc0.20.gd81542e6f3


Reply | Threaded
Open this post in threaded view
|

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

Marc-André Lureau
Spotted by ASAN + minor stylistic change.

Signed-off-by: Marc-André Lureau <[hidden email]>
---
 hw/input/virtio-input.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/hw/input/virtio-input.c b/hw/input/virtio-input.c
index 51617a5885..ec54e46ad6 100644
--- a/hw/input/virtio-input.c
+++ b/hw/input/virtio-input.c
@@ -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);
 }
 
--
2.24.0.rc0.20.gd81542e6f3


Reply | Threaded
Open this post in threaded view
|

[PATCH 2/3] qtest: fix qtest_qmp_device_add leak

Marc-André Lureau
In reply to this post by Marc-André Lureau
Spotted by ASAN.

Signed-off-by: Marc-André Lureau <[hidden email]>
---
 tests/libqtest.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/libqtest.c b/tests/libqtest.c
index 3706bccd8d..91e9cb220c 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -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)
--
2.24.0.rc0.20.gd81542e6f3


Reply | Threaded
Open this post in threaded view
|

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

Marc-André Lureau
In reply to this post by Marc-André Lureau
Spotted by ASAN.

Signed-off-by: Marc-André Lureau <[hidden email]>
---
 tests/cpu-plug-test.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/cpu-plug-test.c b/tests/cpu-plug-test.c
index 058cef5ac1..30e514bbfb 100644
--- a/tests/cpu-plug-test.c
+++ b/tests/cpu-plug-test.c
@@ -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 */
--
2.24.0.rc0.20.gd81542e6f3


Reply | Threaded
Open this post in threaded view
|

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

Laurent Vivier-5
In reply to this post by Marc-André Lureau
On 07/11/2019 20:27, Marc-André Lureau wrote:

> Spotted by ASAN.
>
> Signed-off-by: Marc-André Lureau <[hidden email]>
> ---
>  tests/libqtest.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/tests/libqtest.c b/tests/libqtest.c
> index 3706bccd8d..91e9cb220c 100644
> --- a/tests/libqtest.c
> +++ b/tests/libqtest.c
> @@ -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


Reply | Threaded
Open this post in threaded view
|

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

Marc-André Lureau-2
Hi

On Fri, Nov 8, 2019 at 12:31 AM Laurent Vivier <[hidden email]> wrote:

>
> On 07/11/2019 20:27, Marc-André Lureau wrote:
> > Spotted by ASAN.
> >
> > Signed-off-by: Marc-André Lureau <[hidden email]>
> > ---
> >  tests/libqtest.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/tests/libqtest.c b/tests/libqtest.c
> > index 3706bccd8d..91e9cb220c 100644
> > --- a/tests/libqtest.c
> > +++ b/tests/libqtest.c
> > @@ -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()?

The initial ref is from qobject_from_vjsonf_nofail() constructor


--
Marc-André Lureau

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 0/3] Some memory leak fixes

no-reply
In reply to this post by Marc-André Lureau
Patchew URL: https://patchew.org/QEMU/20191107192731.17330-1-marcandre.lureau@.../



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/20191107192731.17330-1-marcandre.lureau@.../testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 0/3] Some memory leak fixes

Michael S. Tsirkin-4
In reply to this post by Marc-André Lureau
On Thu, Nov 07, 2019 at 11:27:28PM +0400, Marc-André Lureau wrote:
> Hi,
>
> Another bunch of fixes spotted by ASAN when running check-qtest-x86_64.

So who's merging this?

> 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(+)
>
> --
> 2.24.0.rc0.20.gd81542e6f3

Reply | Threaded
Open this post in threaded view
|

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

Michael S. Tsirkin-4
In reply to this post by Marc-André Lureau
On Thu, Nov 07, 2019 at 11:27:29PM +0400, Marc-André Lureau wrote:
> Spotted by ASAN + minor stylistic change.
>
> Signed-off-by: Marc-André Lureau <[hidden email]>

Reviewed-by: Michael S. Tsirkin <[hidden email]>

> ---
>  hw/input/virtio-input.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/hw/input/virtio-input.c b/hw/input/virtio-input.c
> index 51617a5885..ec54e46ad6 100644
> --- a/hw/input/virtio-input.c
> +++ b/hw/input/virtio-input.c
> @@ -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);
>  }
>  
> --
> 2.24.0.rc0.20.gd81542e6f3

Reply | Threaded
Open this post in threaded view
|

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

Thomas Huth-3
In reply to this post by Marc-André Lureau
On 07/11/2019 20.27, Marc-André Lureau wrote:

> Spotted by ASAN.
>
> Signed-off-by: Marc-André Lureau <[hidden email]>
> ---
>   tests/libqtest.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/tests/libqtest.c b/tests/libqtest.c
> index 3706bccd8d..91e9cb220c 100644
> --- a/tests/libqtest.c
> +++ b/tests/libqtest.c
> @@ -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")

Reviewed-by: Thomas Huth <[hidden email]>

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


Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 0/3] Some memory leak fixes

Thomas Huth-3
In reply to this post by no-reply
On 07/11/2019 22.57, [hidden email] wrote:

> Patchew URL: https://patchew.org/QEMU/20191107192731.17330-1-marcandre.lureau@.../
>
> 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")))

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

  Thomas


Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 0/3] Some memory leak fixes

Laurent Vivier-5
On 08/11/2019 10:57, Thomas Huth wrote:

> On 07/11/2019 22.57, [hidden email] wrote:
>> Patchew URL:
>> https://patchew.org/QEMU/20191107192731.17330-1-marcandre.lureau@.../
>>
>>
>> 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")))
>
> 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,


Reply | Threaded
Open this post in threaded view
|

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

Thomas Huth-3
In reply to this post by Marc-André Lureau
On 07/11/2019 20.27, Marc-André Lureau wrote:

> Spotted by ASAN.
>
> Signed-off-by: Marc-André Lureau <[hidden email]>
> ---
>   tests/cpu-plug-test.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/tests/cpu-plug-test.c b/tests/cpu-plug-test.c
> index 058cef5ac1..30e514bbfb 100644
> --- a/tests/cpu-plug-test.c
> +++ b/tests/cpu-plug-test.c
> @@ -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 */
>

Fixes: 021a007efc3 ("cpu-plug-test: fix device_add for pc/q35 machines")

Reviewed-by: Thomas Huth <[hidden email]>


Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 0/3] Some memory leak fixes

Marc-André Lureau-2
In reply to this post by Michael S. Tsirkin-4
Hi

On Fri, Nov 8, 2019 at 1:54 PM Michael S. Tsirkin <[hidden email]> wrote:

>
> On Thu, Nov 07, 2019 at 11:27:28PM +0400, Marc-André Lureau wrote:
> > Hi,
> >
> > Another bunch of fixes spotted by ASAN when running check-qtest-x86_64.
>
> So who's merging this?
>
> > Marc-André Lureau (3):
> >   virtio-input: fix memory leak on unrealize

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

> >   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
>


--
Marc-André Lureau

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 0/3] Some memory leak fixes

Michael S. Tsirkin-4
On Wed, Nov 20, 2019 at 06:50:05PM +0400, Marc-André Lureau wrote:

> Hi
>
> On Fri, Nov 8, 2019 at 1:54 PM Michael S. Tsirkin <[hidden email]> wrote:
> >
> > On Thu, Nov 07, 2019 at 11:27:28PM +0400, Marc-André Lureau wrote:
> > > Hi,
> > >
> > > Another bunch of fixes spotted by ASAN when running check-qtest-x86_64.
> >
> > So who's merging this?
> >
> > > 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.

> > >   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
> >
>
>
> --
> Marc-André Lureau