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

Re: [XEN PATCH] docs/misra: document the C dialect and translation toolchain assumptions.


  • To: Roberto Bagnara <roberto.bagnara@xxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 19 Jun 2023 13:47:16 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; 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=o2fofnB+rICKpanQR6oRLBZEmRSm48bomD9i5pl6gEs=; b=K1II05NmtFyLyNi8hXQd2Sb7Ap3kBUdQ0lQ3796IfH0QFe0U1GDJg50ntJEFDpNdWzmbhrnZKicdekMGdNa0N9WCNjo0i67Y/VerMKADHL5F8KF1nG2KnXP/DL3/mlescW4dI+WtVEJHL4LoC/MONUsWIIgRpfr+90CeqqN9Qpk8wCoURCKSqYMfkRY2rUmdfngc7tFERVwOF2kmqP0q1IGHcYfNQXZNlizJtlbdd0EGpFjUrY9r9J0ilqWf1qobmE2ItvtQpycVUtwcFL1bsD8nPrBydIrruYoZg2jAeujojrRGAJFjiSNfL7caTp4eer4vA9E3sYs/0rr2UGVSnQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i8tonfcrtq/u1VKd28I/9LExJsvqWmnB7phIKSWGKP/s3olnwIUnrACprpqopx60mMCR7tO7zq40m0mnutD4p9cSJ15iBQc8E+hmDwXxyf8IXFhtq+FziF1tJrJtQA8IuuB8rPogTvJ0UejDEeCBNGBJKwrFu3kR3jKQcYC6tMLDqtiLDfP2T1/fsfkqhuIyvu6GDlK4MnULZ+oPtlyHBio6fGUCG0/nrCHNMrdeCd682YhMvghO+Tlxey4aJVrXzxm/nVPisKK075mWw47y/GGlJnS5XED4qU9Vj9r0iOuo5GKyQJS2l+1A4cd7y3dVZMFgdV9jewbzTFKYM3jqAQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, consulting@xxxxxxxxxxx, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Wei Liu <wl@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • Delivery-date: Mon, 19 Jun 2023 11:47:28 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 19.06.2023 12:53, Roberto Bagnara wrote:
> On 19/06/23 09:54, Jan Beulich wrote:
>> On 16.06.2023 17:54, Roberto Bagnara wrote:
>>> On 16/06/23 01:26, Stefano Stabellini wrote:
>>>> On Thu, 15 Jun 2023, Roberto Bagnara wrote:
>>>>> +       static function is used in an inline function with external 
>>>>> linkage:
>>>>> +          non-documented GCC extension.
>>>>
>>>> I am not sure if I follow about this one. Did you mean "static is used
>>>> in an inline function with external linkage" ?
>>>
>>> An inline function with external linkage can be inlined everywhere.
>>> If that calls a static functions, which is not available everywhere,
>>> the behavior is not defined.
>>
>> I guess I could do with an example where this leads to UB. What I'd expect
>> is that it leads to a compilation error.
> 
> Here are the two occurrences we have in ARM64 code:
> 
> violation for rule MC3R1.R1.1: (required) The program shall contain no 
> violations of the standard C syntax and constraints, and shall not exceed the 
> implementation's translation limits.
> xen/common/spinlock.c:316.29-316.40: Loc #1 [culprit: static function 
> `observe_head(spinlock_tickets_t*)' is used in an inline function with 
> external linkage (ill-formed for the C99 standard, ISO/IEC 9899:1999: "An 
> ill-formed source detected by the parser."
> xen/common/spinlock.c:301.26-301.37: Loc #2 [evidence: 
> `observe_head(spinlock_tickets_t*)' declared here]
> xen/include/xen/spinlock.h:180.1-180.4: Loc #3 [evidence: use 'static' to 
> give inline function `_spin_lock_cb(spinlock_t*, void(*)(void*), void*)' 
> internal linkage]
> 
> violation for rule MC3R1.R1.1: (required) The program shall contain no 
> violations of the standard C syntax and constraints, and shall not exceed the 
> implementation's translation limits.
> xen/common/spinlock.c:324.5-324.12: Loc #1 [culprit: static function 
> `got_lock(union lock_debug*)' is used in an inline function with external 
> linkage (ill-formed for the C99 standard, ISO/IEC 9899:1999: "An ill-formed 
> source detected by the parser."
> xen/common/spinlock.c:227.13-227.20: Loc #2 [evidence: `got_lock(union 
> lock_debug*)' declared here]
> xen/include/xen/spinlock.h:180.1-180.4: Loc #3 [evidence: use 'static' to 
> give inline function `_spin_lock_cb(spinlock_t*, void(*)(void*), void*)' 
> internal linkage]

I know _spin_lock_cb() was an example of a violation (it isn't anymore),
but this does not serve as an example for the UB you claim may occur.
The "inline" there was in a .c file, and hence the function could only
be inlined with its (static) helper also in scope.

Jan



 


Rackspace

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