[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] lib: extend ASSERT()


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: George Dunlap <George.Dunlap@xxxxxxxxxx>
  • Date: Wed, 16 Feb 2022 11:34:21 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YsdX51WXsh9P2Sj+L7xGle/P8pJ6O5xUJG2Rw6EWCc8=; b=MpT0QeUKyWjJlIOJP/spAYoWWTl5JdKSFFgtALLzkx1wkqHv5MH+r5BdUc5neA1H7lxWMQoD5y+MXmKqOZYzB8g3vdodlhuPb6IDEsE+PjMjDqqzDTZNniA9synyc1g/aGNC2Jb8s9VlZZoNBgRZ5WCkuor2erkUclyS3E8Hlis9VbXzZ6dOmym30gNDaKxpN1bi4CB0xnZZh8MJ4NV1wFGbJsQw7nt30DuBc4wEO3T7+Y9cbMUIGdq0aa0AP7vHov0VUzD9zKGj8DieWzBOE4Q7YxC2+f/zSGZ+ArcdcyPbnYaKc89ByA8tGxI3rHqZral833liMbWKIpSdfKAfnQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kaqRwGpva5iQm9cREGeYTMco/16Nk/fC5jm8RSPwPmBxNxsk+mIxNLXXo3nYRJfzl2QJwFKjnbQmV8shfbQw0SInbdWSv7BLVEy7IWd/HBiZLSU7KH9dBKcKgQJoUGeJB1gl6EoH5QNpFg9gQUtFbXWHtxs8PS2oEm/omVce3fUBucdAObid/ji1bQbQ982lttIwwzGbuzGyHqqVNdxQUEkrlxNUbrnyV7gCYlBdwTk/Z7QPvKFzjQ5glBt00Q3gEOrYD5DQaKBgBzWQz0xHu2Ig/Z43xXkmkr2sGy7X8LP82WNuCD8570KZneXYrzUGAAO5aHy+r5GcGx7tbOoDpA==
  • Authentication-results: esa1.hc3370-68.iphmx.com; dkim=hardfail (body hash did not verify [final]) header.i=@citrix.onmicrosoft.com
  • Cc: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "Andrew Cooper" <Andrew.Cooper3@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>
  • Delivery-date: Wed, 16 Feb 2022 11:34:33 +0000
  • Ironport-data: A9a23:X5zeoK/DPJDS6MmYUfGDDrUDiniTJUtcMsCJ2f8bNWPdYAuX7wSz/ BJcAD7Ya7vPIDfrKpolWDmFhR4AucfXmoU2TQdrrS41QikUopLPW4rAJBigZHqfdJKfEhg34 pkUNIWfcJ8+QnaM+Bvwa7G5o3Ali6+GGbalAbGs1kydPeNBYH5JZUVLx75p6mIRveWEPu+th T/Ti5zRZwP/0mMsaTxNuvnY9Esy4v2q4GkWtAVvPf4XsgSOxiUZVJ4RG/q8fiDyKmV28k9WZ AphIJWRpD6xE8IFU4v9+lrDn8ljrof6ZWBisFIPM0SZqkUE9nxaPpoTbqJGMx8N0mvRxrid9 f0W3XCOYVZxVkHzsLx1vylwS0mS6oUfpdcriVDm2SCi5xWun0nEmp2CP2lvVWEswc5lAHkmy BAtAGtlgiZvJQ6B6OnTpuFE3qzPJSRwVW8VkikIITrxVZ7KTX1fKkljCBAxMDoY36hz8fjii 8UxZH1wQk7pbUB2KgkxWJIht9mloWLzSmgNwL6VjfJfD2n7yQVw1P7mMcbPe8zMTsJQ9qqaj juYpSKjWEhcbYHBj2remp6vrrancSfTd48VDrK1sNJ3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2NsINGsqw91CgWooDLnd8DwD96Ogj1S6ck ELoBGKcfynTA/WkVoGHBFRGL13F0NQqEkP0V9GWnvXwXItjZB2xsnEwFqlYrd7yOtGFdUC7foo pkG//mL6D9DVEPe1gwatknf+
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHYE4shsIFDV42A206yi2y9mPx4ZqyVNw0AgADQCYCAAAHgAIAAIi+A
  • Thread-topic: [PATCH v2] lib: extend ASSERT()


> On Feb 16, 2022, at 9:31 AM, Jan Beulich <jbeulich@xxxxxxxx> wrote:
> 
> On 16.02.2022 10:25, Bertrand Marquis wrote:
>> Hi Jan, Julien,
>> 
>>> On 15 Feb 2022, at 21:00, Julien Grall <julien@xxxxxxx> wrote:
>>> 
>>> (+ Bertrand)
>>> 
>>> Hi Jan,
>>> 
>>> On 27/01/2022 14:34, Jan Beulich wrote:
>>>> The increasing amount of constructs along the lines of
>>>>    if ( !condition )
>>>>    {
>>>>        ASSERT_UNREACHABLE();
>>>>        return;
>>>>    }
>>>> is not only longer than necessary, but also doesn't produce incident
>>>> specific console output (except for file name and line number).
>>> 
>>> So I agree that this construct will always result to a minimum 5 lines. 
>>> Which is not nice. But the proposed change is...
>>> 
>>>> Allow
>>>> the intended effect to be achieved with ASSERT(), by giving it a second
>>>> parameter allowing specification of the action to take in release builds
>>>> in case an assertion would have triggered in a debug one. The example
>>>> above then becomes
>>>>    ASSERT(condition, return);
>>>> Make sure the condition will continue to not get evaluated when just a
>>>> single argument gets passed to ASSERT().
>>>> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
>>>> ---
>>>> v2: Rename new macro parameter.
>>>> ---
>>>> RFC: The use of a control flow construct as a macro argument may be
>>>>     controversial.
>>> 
>>> indeed controversial. I find this quite confusing and not something I would 
>>> request a user to switch to if they use the longer version.
>>> 
>>> That said, this is mainly a matter of taste. So I am interested to hear 
>>> others view.
>>> 
>>> I have also CCed Bertrand to have an opinions from the Fusa Group (I 
>>> suspect this will go backward for them).
>> 
>> Thanks and here is my feedback in regards to Fusa here.
>> 
>> Most certification standards are forbidding completely macros including
>> conditions (and quite a number are forbidding static inline with conditions).
>> The main reason for that is MCDC coverage (condition/decisions and not only
>> code line) is not possible to do anymore down to the source code and has to 
>> be
>> done down to the pre-processed code.
>> 
>> Out of Fusa considerations, one thing I do not like in this solution is the 
>> fact that
>> you put some code as parameter of the macro (the return).
>> 
>> To make this a bit better you could put the return code as parameter
>> instead of having “return CODE” as parameter.
> 
> Except that it's not always "return" what you want, and hence it
> can't be made implicit.
> 
>> An other thing is that Xen ASSERT after this change will be quite different 
>> from
>> any ASSERT found in other projects which could make it misleading for 
>> developers.
>> Maybe we could introduce an ASSERT_RETURN macros instead of modifying the
>> behaviour of the standard ASSERT ?
> 
> Along the lines of the above, this would then mean a multitude of
> new macros.

Out of curiosity, what kinds of other actions?

I am opposed to overloading “ASSERT” for this new kind of macro; I think it 
would not only be unnecessarily confusing to people not familiar with our 
codebase, but it would be too easy for people to fail to notice which macro was 
being used.

ASSERT_ACTION(condition, code) (or even ASSERT_OR_ACTION()) would be a bare 
minimum for me.

But I can’t imagine that there are more than a handful of actions we might want 
to take, so defining a macro for each one shouldn’t be too burdensome.

Furthermore, the very flexibility seems dangerous; you’re not seeing what 
actual code is generated, so it’s to easy to be “clever”, and/or write code 
that ends up doing something different than you expect.

At the moment I think ASSERT_OR_RETURN(condition, code), plus other new macros 
for the other behavior is needed, would be better.

 -George

Attachment: signature.asc
Description: Message signed with OpenPGP


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.