From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 8924CD12241; Thu, 20 Jun 2024 13:01:35 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 8924CD12241 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1718877695; bh=asl7gUAtS7yiuXdocwdVPYTjsfs7YwN4YhFHRnZDb8Q=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=FwG04KFHi7VdkDwd4nlealMUHT6cDDRKtCsUbAvH1OghQpJG0dlLHPKRA7na4g9sF 7R3ajOw9DK4NDUoiS0tecFMHW3eVMLRqI+01Kn3PeT7b6QMPBi4TzhstEkOdMNSoqV UIx0sDbl4+vUD2WfdCg98nm7/TBysxwK1CYBBMOc= Received: from smtp57.i.mail.ru (smtp57.i.mail.ru [95.163.41.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 4059FD1225A for ; Thu, 20 Jun 2024 13:01:34 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 4059FD1225A Received: by smtp57.i.mail.ru with esmtpa (envelope-from ) id 1sKEbk-0000000BmBS-2g6b; Thu, 20 Jun 2024 13:01:33 +0300 Content-Type: multipart/alternative; boundary="------------Ud28c0D8w03c5Z67JcwCc24i" Message-ID: Date: Thu, 20 Jun 2024 13:01:30 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Sergey Kaplun , Maxim Kokryashkin Cc: tarantool-patches@dev.tarantool.org References: <6f8a08e1823bfceebb4057207ee2f2bdb7d2d47c.1715776117.git.skaplun@tarantool.org> In-Reply-To: X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9EB52AADBDB11C149350D4355FB13A719A9F27761C20B8EF8182A05F5380850402DEA8D680D4C5F6533594132A326AF8BB39B236343DF996AE22186B0D289455DFD3330C560CA6F5B X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7F40AD8E56E74C9F0EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006377BA6DB23C50317A38638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8D87F57B226B844F99C7DA63C3F91A6607B1E29B8261699A8CC7F00164DA146DAFE8445B8C89999728AA50765F7900637CAEE156C82D3D7D9389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC8A9FF340AA05FB58CF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA73AA81AA40904B5D9A18204E546F3947C2D01283D1ACF37BA2D242C3BD2E3F4C64AD6D5ED66289B523666184CF4C3C14F6136E347CC761E07725E5C173C3A84C319D302B05D018AA3BA3038C0950A5D36B5C8C57E37DE458B330BD67F2E7D9AF16D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166176DF2183F8FC7C04E672349037D5FA5725E5C173C3A84C3EB9EA62DB0D2896935872C767BF85DA2F004C90652538430E4A6367B16DE6309 X-C1DE0DAB: 0D63561A33F958A58C05B06EDCA9A0AD5002B1117B3ED69635EB91AEB423FE97361FAC1196A180DE823CB91A9FED034534781492E4B8EEAD9CFA8CFAC159CE19BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADBF74143AD284FC7177DD89D51EBB7742424CF958EAFF5D571004E42C50DC4CA955A7F0CF078B5EC49A30900B95165D3482189E76C6218D8FDAC8D6D5B3CB47A91F0B79BC53FC059FE9EF5E0633B325B4114BCDE807078B081D7E09C32AA3244C5DD68095F327BEEC7B0DC8E7D22A103A9120E9A6EBDBF360EA455F16B58544A2557BDE0DD54B3590A5AE236DF995FB59978A700BF655EAEEED6A17656DB59BCAD427812AF56FC65B X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojstWfowt7DqKi+AXMTLiCnA== X-Mailru-Sender: 49D287FBCBBF3A5C1D5C29A1EFFD41C37125F7A1874FC598B951B70A5BD4BD8EDEB9C7FA5DF7CAF37CF96F699FB25259EBA65886582A37BD66FEC6BF5C9C28D98A98C1125256619760D574B6FC815AB872D6B4FCE48DF648AE208404248635DF X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 1/2] build: introduce LUAJIT_USE_UBSAN option X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Sergey Bronnikov via Tarantool-patches Reply-To: Sergey Bronnikov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" This is a multi-part message in MIME format. --------------Ud28c0D8w03c5Z67JcwCc24i Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi, Sergey, On 16.05.2024 13:14, Sergey Kaplun wrote: > Hi, folks! > Some more thoughts below. > > On 15.05.24, Sergey Kaplun wrote: > > > >> + string(JOIN "," UBSAN_IGNORE_OPTIONS >> + # Misaligned pseudo-pointers are used to determine internal >> + # variable names inside the `for` cycle. >> + alignment >> + # Not interested in float cast overflow errors. >> + float-cast-overflow >> + # NULL checking is disabled because this is not a UB and >> + # raises lots of false-positive fails. >> + null > Maybe it is worth to add also "nonnull-attribute" to the ignore options: > > ``` > LSAN_OPTIONS="abort_on_error=1" src/luajit -e 'error("bad usage", 3)' > /home/burii/builds_workspace/luajit/gh-8473-ubsan/src/lj_buf.h:75:25: runtime error: null pointer passed as argument 1, which is declared to never be null > /usr/include/string.h:44:28: note: nonnull attribute specified here > ``` > > Here, `memcpy()` gets the NULL pointer as the first argument and the > `len` == 0. So there are no problems here. Also, the nullability > violation is not a UB, as mentioned in the documentation. > > Thoughts? I agree with arguments provided by Maxim - it's UB, the standard states it clearly, and it should be fixed. I propose to do the following: - suppress the check (add it to UBSAN_IGNORE_OPTIONS) with appropriate comment (something like "we know it is bad, but it is unfixed in upstream, we will wait a fix"). Probably we should suppress it per file like you did with other checks. - send a fix to upstream or submit an issue to the upstream (I'll not insist, but it would be desirable) > >> + # Not interested in checking arithmetic with NULL. >> + pointer-overflow >> + # Shifts of negative numbers are widely used in parsing ULEB, >> + # cdata arithmetic, vmevent hash calculation, etc. >> + shift-base >> + ) --------------Ud28c0D8w03c5Z67JcwCc24i Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

Hi, Sergey,

On 16.05.2024 13:14, Sergey Kaplun wrote:
Hi, folks!
Some more thoughts below.

On 15.05.24, Sergey Kaplun wrote:

<snipped>

+  string(JOIN "," UBSAN_IGNORE_OPTIONS
+    # Misaligned pseudo-pointers are used to determine internal
+    # variable names inside the `for` cycle.
+    alignment
+    # Not interested in float cast overflow errors.
+    float-cast-overflow
+    # NULL checking is disabled because this is not a UB and
+    # raises lots of false-positive fails.
+    null
Maybe it is worth to add also "nonnull-attribute" to the ignore options:

```
LSAN_OPTIONS="abort_on_error=1" src/luajit -e 'error("bad usage", 3)'
/home/burii/builds_workspace/luajit/gh-8473-ubsan/src/lj_buf.h:75:25: runtime error: null pointer passed as argument 1, which is declared to never be null
/usr/include/string.h:44:28: note: nonnull attribute specified here
```

Here, `memcpy()` gets the NULL pointer as the first argument and the
`len` == 0. So there are no problems here. Also, the nullability
violation is not a UB, as mentioned in the documentation.

Thoughts?

I agree with arguments provided by Maxim - it's UB, the standard states it clearly,

and it should be fixed. I propose to do the following:

- suppress the check (add it to UBSAN_IGNORE_OPTIONS) with appropriate comment

(something like "we know it is bad, but it is unfixed in upstream, we will wait a fix").

Probably we should suppress it per file like you did with other checks.

- send a fix to upstream or submit an issue to the upstream (I'll not insist, but it would be desirable)


+    # Not interested in checking arithmetic with NULL.
+    pointer-overflow
+    # Shifts of negative numbers are widely used in parsing ULEB,
+    # cdata arithmetic, vmevent hash calculation, etc.
+    shift-base
+  )

    
--------------Ud28c0D8w03c5Z67JcwCc24i--