[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 2/3] qobject: introduce QObjectCommon
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH v2 2/3] qobject: introduce QObjectCommon |
Date: |
Wed, 28 Mar 2018 16:11:28 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 |
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
[Qemu-devel] [PATCH v2 1/3] qobject: ensure base is at offset 0, Marc-André Lureau, 2018/03/28
[Qemu-devel] [PATCH v2 3/3] qobject: replace qobject_incref/QINCREF qobject_decref/QDECREF, Marc-André Lureau, 2018/03/28