From: Markus Armbruster <armbru@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: "Daniel Hoffman" <dhoff749@gmail.com>,
qemu-devel@nongnu.org, qemu-trivial@nongnu.org,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Eduardo Habkost" <eduardo@habkost.net>
Subject: Re: [PATCH] hw/core: define stack variable to NULL to fix qtest with sanitizers
Date: Fri, 24 Nov 2023 14:39:24 +0100 [thread overview]
Message-ID: <87sf4vgtir.fsf@pond.sub.org> (raw)
In-Reply-To: <93f7ee3e-a92f-4b18-bf16-2169c8b2791d@linaro.org> ("Philippe Mathieu-Daudé"'s message of "Fri, 24 Nov 2023 11:07:06 +0100")
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> (Cc'ing QAPI maintainer)
>
> On 24/11/23 02:53, Daniel Hoffman wrote:
>> This was the only failure preventing `make check` from passing with sanitizers
>> enabled on my configuration.
>
> IIUC this is due to visit_start_list() which expects a NULL list,
> see qapi/qapi-visit-core.c:
>
> bool visit_start_list(Visitor *v, const char *name, GenericList **list,
> size_t size, Error **errp)
> {
> bool ok;
>
> assert(!list || size >= sizeof(GenericList));
This asserts either "if real walk, then size is sane".
>
> which is well defined in its declaration:
>
> /*
> * Start visiting a list.
> *
> * @name expresses the relationship of this list to its parent
> * container; see the general description of @name above.
> *
> * @list must be non-NULL for a real walk, in which case @size
> * determines how much memory an input or clone visitor will allocate
> * into *@list (at least sizeof(GenericList)). Some visitors also
> * allow @list to be NULL for a virtual walk, in which case @size is
> * ignored.
> ...
Mind the number of *!
The function contract talks about @list, which is GenericList **.
get_prop_array() passes &list, where list is GenericList *. &list is
non-null even before the patch.
The patch initializes @list to empty.
> With the patch description improved:
Specifically, show how things fail under sanitation.
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>
>> Signed-off-by: Daniel Hoffman <dhoff749@gmail.com>
>> ---
>> hw/core/qdev-properties.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
>> index 91632f7be9f..4caa78b7bc5 100644
>> --- a/hw/core/qdev-properties.c
>> +++ b/hw/core/qdev-properties.c
>> @@ -690,7 +690,7 @@ static void get_prop_array(Object *obj, Visitor *v, const char *name,
>> uint32_t *alenptr = object_field_prop_ptr(obj, prop);
>> void **arrayptr = (void *)obj + prop->arrayoffset;
>> char *elem = *arrayptr;
>> - GenericList *list;
>> + GenericList *list = NULL;
>> const size_t list_elem_size = sizeof(*list) + prop->arrayfieldsize;
>> int i;
>> bool ok;
if (!visit_start_list(v, name, &list, list_elem_size, errp)) {
return;
}
next prev parent reply other threads:[~2023-11-24 13:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-24 1:53 [PATCH] hw/core: define stack variable to NULL to fix qtest with sanitizers Daniel Hoffman
2023-11-24 10:07 ` Philippe Mathieu-Daudé
2023-11-24 13:39 ` Markus Armbruster [this message]
2023-11-24 14:02 ` Markus Armbruster
2023-11-24 16:59 ` Dan Hoffman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87sf4vgtir.fsf@pond.sub.org \
--to=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=dhoff749@gmail.com \
--cc=eduardo@habkost.net \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.