qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Christian Schoenebeck <qemu_oss@crudebyte.com>
To: qemu-devel@nongnu.org
Cc: "Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"Akihiko Odaki" <akihiko.odaki@gmail.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Daniel P . Berrange" <berrange@redhat.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Gerd Hoffmann" <kraxel@redhat.com>
Subject: Re: [PATCH] ui/gtk: fix NULL pointer dereference
Date: Mon, 08 Mar 2021 15:57:56 +0100	[thread overview]
Message-ID: <2232725.kIh4fn7MiB@silver> (raw)
In-Reply-To: <2f4c50c9-930f-b820-b507-d9e43da20093@redhat.com>

On Montag, 8. März 2021 15:30:23 CET Philippe Mathieu-Daudé wrote:
> On 3/8/21 3:17 PM, Akihiko Odaki wrote:
> > 2021年3月8日(月) 23:03 Christian Schoenebeck <qemu_oss@crudebyte.com>:
> >> BTW, there is __nonnull supported by clang, e.g.:
> >> 
> >> static void foo(void *__nonnull p) {
> >> 
> >>         ...
> >> 
> >> }
> >> 
> >> Maybe as an optionally defined macro (if supported by compiler) this
> >> could be a useful tool for such intended nonnull designs, as it
> >> immediately emits compiler errors.
> >> 
> >> Best regards,
> >> Christian Schoenebeck
> > 
> > GCC has nonnull attribute and clang accepts it too. However, it
> > specifies argument indices, which is harder to understand and to
> > maintain.
> > __attribute__((nonnull(2)))
> > void f(void *k, void *l);
> 
> Richard once suggested to add QEMU_NONNULL(), I have been using
> it on a series trying to enforce non-null uses of QOM
> 'struct Object *owner' but it didn't work out because migrations
> of MemoryRegion, some have NULL owner in MachineState.
> 
> I also discarded it because Daniel said it could have side-effects
> https://www.mail-archive.com/qemu-devel@nongnu.org/msg720739.html

Yes, but the optimizer part could be disabled with
-fno-delete-null-pointer-checks which would render it a pure diagnostic
feature:

https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-nonnull-function-attribute

Is there an example where the compiler failed to detect a NULL user case?

Best regards,
Christian Schoenebeck




  reply	other threads:[~2021-03-08 14:59 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-07 19:38 [PATCH] ui/gtk: fix NULL pointer dereference Christian Schoenebeck
2021-03-08  3:45 ` Akihiko Odaki
2021-03-08 10:39   ` Christian Schoenebeck
2021-03-08 11:31     ` Akihiko Odaki
2021-03-08 12:42       ` Christian Schoenebeck
2021-03-08 13:21         ` Akihiko Odaki
2021-03-08 13:37         ` Peter Maydell
2021-03-08 13:57           ` Akihiko Odaki
2021-03-08 14:03           ` Christian Schoenebeck
2021-03-08 14:17             ` Akihiko Odaki
2021-03-08 14:30               ` Philippe Mathieu-Daudé
2021-03-08 14:57                 ` Christian Schoenebeck [this message]
2021-03-09  4:20                   ` Akihiko Odaki

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=2232725.kIh4fn7MiB@silver \
    --to=qemu_oss@crudebyte.com \
    --cc=akihiko.odaki@gmail.com \
    --cc=berrange@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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).