[PULL 09/13] ui/pixman: Consistent error handling in qemu_pixman_shareable_free()

Markus Armbruster posted 13 patches 1 month, 2 weeks ago
Maintainers: Jonathan Cameron <jonathan.cameron@huawei.com>, Fan Ni <fan.ni@samsung.com>, "Michael S. Tsirkin" <mst@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>, Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>, Dmitry Osipenko <dmitry.osipenko@collabora.com>, Gustavo Romero <gustavo.romero@linaro.org>, Jason Wang <jasowang@redhat.com>, Elena Ufimtseva <elena.ufimtseva@oracle.com>, Jagannathan Raman <jag.raman@oracle.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Markus Armbruster <armbru@redhat.com>, Michael Roth <michael.roth@amd.com>, Stefan Weil <sw@weilnetz.de>, "Daniel P. Berrangé" <berrange@redhat.com>, Steve Sistare <steven.sistare@oracle.com>, Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>, "Dr. David Alan Gilbert" <dave@treblig.org>, Samuel Thibault <samuel.thibault@ens-lyon.org>, Richard Henderson <richard.henderson@linaro.org>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>, Fam Zheng <fam@euphon.net>
There is a newer version of this series
[PULL 09/13] ui/pixman: Consistent error handling in qemu_pixman_shareable_free()
Posted by Markus Armbruster 1 month, 2 weeks ago
qemu_pixman_shareable_free() wraps around either qemu_memfd_free() or
qemu_win32_map_free().  The former reports trouble as error, with
error_report(), then succeeds.  The latter reports it as warning (we
pass it &error_warn), then succeeds.

Change the latter to report as error, too.

Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20250923091000.3180122-10-armbru@redhat.com>
Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
---
 ui/qemu-pixman.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/ui/qemu-pixman.c b/ui/qemu-pixman.c
index ef4e71da11..e46c6232cf 100644
--- a/ui/qemu-pixman.c
+++ b/ui/qemu-pixman.c
@@ -288,7 +288,10 @@ qemu_pixman_shareable_free(qemu_pixman_shareable handle,
                            void *ptr, size_t size)
 {
 #ifdef WIN32
-    qemu_win32_map_free(ptr, handle, &error_warn);
+    Error *err = NULL;
+
+    qemu_win32_map_free(ptr, handle, &err);
+    error_report_err(err);
 #else
     qemu_memfd_free(ptr, size, handle);
 #endif
-- 
2.49.0


Re: [PULL 09/13] ui/pixman: Consistent error handling in qemu_pixman_shareable_free()
Posted by Bernhard Beschow 1 month ago

Am 30. September 2025 12:46:49 UTC schrieb Markus Armbruster <armbru@redhat.com>:
>qemu_pixman_shareable_free() wraps around either qemu_memfd_free() or
>qemu_win32_map_free().  The former reports trouble as error, with
>error_report(), then succeeds.  The latter reports it as warning (we
>pass it &error_warn), then succeeds.
>
>Change the latter to report as error, too.
>
>Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
>Signed-off-by: Markus Armbruster <armbru@redhat.com>
>Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>Message-ID: <20250923091000.3180122-10-armbru@redhat.com>
>Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
>---
> ui/qemu-pixman.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
>diff --git a/ui/qemu-pixman.c b/ui/qemu-pixman.c
>index ef4e71da11..e46c6232cf 100644
>--- a/ui/qemu-pixman.c
>+++ b/ui/qemu-pixman.c
>@@ -288,7 +288,10 @@ qemu_pixman_shareable_free(qemu_pixman_shareable handle,
>                            void *ptr, size_t size)
> {
> #ifdef WIN32
>-    qemu_win32_map_free(ptr, handle, &error_warn);
>+    Error *err = NULL;
>+
>+    qemu_win32_map_free(ptr, handle, &err);
>+    error_report_err(err);

The last line causes a crash on Windows since error_report_err() expects err to be non-NULL. This can be reproduced by invoking `qemu-system-x86_64.exe` without any parameters in msys2. Removing the line fixes the crash. I'm not sure how to fix this, otherwise I had went for it myself.

Best regards,
Bernhard

> #else
>     qemu_memfd_free(ptr, size, handle);
> #endif
Re: [PULL 09/13] ui/pixman: Consistent error handling in qemu_pixman_shareable_free()
Posted by Markus Armbruster 1 month ago
Bernhard Beschow <shentey@gmail.com> writes:

> Am 30. September 2025 12:46:49 UTC schrieb Markus Armbruster <armbru@redhat.com>:
>>qemu_pixman_shareable_free() wraps around either qemu_memfd_free() or
>>qemu_win32_map_free().  The former reports trouble as error, with
>>error_report(), then succeeds.  The latter reports it as warning (we
>>pass it &error_warn), then succeeds.
>>
>>Change the latter to report as error, too.
>>
>>Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
>>Signed-off-by: Markus Armbruster <armbru@redhat.com>
>>Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>>Message-ID: <20250923091000.3180122-10-armbru@redhat.com>
>>Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
>>---
>> ui/qemu-pixman.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>>diff --git a/ui/qemu-pixman.c b/ui/qemu-pixman.c
>>index ef4e71da11..e46c6232cf 100644
>>--- a/ui/qemu-pixman.c
>>+++ b/ui/qemu-pixman.c
>>@@ -288,7 +288,10 @@ qemu_pixman_shareable_free(qemu_pixman_shareable handle,
>>                            void *ptr, size_t size)
>> {
>> #ifdef WIN32
>>-    qemu_win32_map_free(ptr, handle, &error_warn);
>>+    Error *err = NULL;
>>+
>>+    qemu_win32_map_free(ptr, handle, &err);
>>+    error_report_err(err);
>
> The last line causes a crash on Windows since error_report_err() expects err to be non-NULL. This can be reproduced by invoking `qemu-system-x86_64.exe` without any parameters in msys2. Removing the line fixes the crash. I'm not sure how to fix this, otherwise I had went for it myself.

My bad.  I'll fix it.  Thanks!

> Best regards,
> Bernhard
>
>> #else
>>     qemu_memfd_free(ptr, size, handle);
>> #endif