All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Eric Blake" <eblake@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: qemu-devel <qemu-devel@nongnu.org>,
	"Armbruster, Markus" <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 2/3] qobject: introduce QObjectCommon
Date: Wed, 28 Mar 2018 16:11:28 +0200	[thread overview]
Message-ID: <6fca462f-7aca-f743-6f43-8475b6501014@redhat.com> (raw)
In-Reply-To: <ac132600-ac94-c9b7-b280-f2ff2ebebf74@redhat.com>

On 28/03/2018 15:55, Eric Blake wrote:
> On 03/28/2018 08:48 AM, Marc-André Lureau wrote:
> 
>>>> +#define QOBJECT(x) \
>>>> +   container_of(&(x)->base, QObject, base)
>>>
>>>
>>> If I understand correctly, this still causes clang complaints when
>>> called as
>>> QOBJECT(NULL).  As long as we are touching this, should we improve this
>>> macro to be friendly to NULL conversion?
>>
>> I don't see much need for allowing NULL (literally) to be passed to
>> QOBJECT(). If it's a null pointer, as long as it has the right type,
>> it should be fine, shouldn't it?
> 
> Not with clang ubsan (okay, the failure is at runtime, not compile time):
> 
> https://lists.gnu.org/archive/html/qemu-devel/2018-03/msg05143.html
> https://lists.gnu.org/archive/html/qemu-devel/2018-03/msg05148.html
> 
> Even when the offset is 0, the mere fact that you are computing an
> offset relative to a NULL pointer is undefined behavior.

Are there cases where we are passing NULL to qobject_{inc,dec}ref?  They
currently have an "if" in they're body, but my opinion is they ought to
crash and burn...

Paolo

  reply	other threads:[~2018-03-28 14:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-28 13:07 [Qemu-devel] [PATCH v2 0/3] RFC: simplify qobject refcount Marc-André Lureau
2018-03-28 13:07 ` [Qemu-devel] [PATCH v2 1/3] qobject: ensure base is at offset 0 Marc-André Lureau
2018-03-28 13:07 ` [Qemu-devel] [PATCH v2 2/3] qobject: introduce QObjectCommon Marc-André Lureau
2018-03-28 13:45   ` Eric Blake
2018-03-28 13:48     ` Marc-André Lureau
2018-03-28 13:55       ` Eric Blake
2018-03-28 14:11         ` Paolo Bonzini [this message]
2018-03-28 14:19           ` Marc-André Lureau
2018-03-28 13:07 ` [Qemu-devel] [PATCH v2 3/3] qobject: replace qobject_incref/QINCREF qobject_decref/QDECREF Marc-André Lureau

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=6fca462f-7aca-f743-6f43-8475b6501014@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --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 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.