qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: John Snow <jsnow@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>,
	QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] qtest protocol: should memset/read/write etc of a size of 0 bytes be permitted?
Date: Thu, 4 Aug 2016 14:49:18 -0400	[thread overview]
Message-ID: <1ab0c4f6-b927-55fc-7e7e-84c135edd143@redhat.com> (raw)
In-Reply-To: <CAFEAcA9Hr_xicYgob-1viu9+vOZ8kuFhuym10gcx5mHF=pC_0Q@mail.gmail.com>



On 08/04/2016 02:46 PM, Peter Maydell wrote:
> I've upgraded to a more recent version of clang, which now produces
> undefined-behaviour warnings for passing NULL pointers to some library
> functions. One of the things it has shown up is that some of the
> qtest tests ask for "memset" with size zero. In our current implementation
> this results in qtest.c calling g_malloc(0), which returns NULL, and
> then calling memset(NULL, chr, 0), which is UB.
>
> So should we:
> (1) declare the qtest protocol commands 'memset', 'read', 'write'
> etc which operate on a lump of guest memory of specified size to
> support size == 0 as meaning "do nothing"

This would be easy to do.

> (2) declare that size == 0 is not valid and make it return a failure
> code back down the qtest pipe (and fix the offending tests)
>

This is probably the nicer thing to do -- if memset of length 0 is 
undefined, probably qmemset and friends should also be undefined by 
extension.

I reserve the right to change my mind depending on how gnarly it is to 
untangle.

I assume you're hoping for 2.7.

> ?
>
> The offending tests are i386/ahci/flush/simple and i386/ahci/max
> (because ahci_io() calls qmemset() with a zero size.)
>
> thanks
> -- PMM
>

--js

  reply	other threads:[~2016-08-04 18:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-04 18:46 [Qemu-devel] qtest protocol: should memset/read/write etc of a size of 0 bytes be permitted? Peter Maydell
2016-08-04 18:49 ` John Snow [this message]
2016-08-04 20:11   ` Peter Maydell
2016-08-04 20:39 ` Eric Blake
2016-08-05  6:46   ` Markus Armbruster
2016-08-05  9:47     ` Peter Maydell

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=1ab0c4f6-b927-55fc-7e7e-84c135edd143@redhat.com \
    --to=jsnow@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).