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 9CF9BB8A883; Mon, 27 May 2024 11:52:33 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 9CF9BB8A883 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1716799953; bh=scIJ1H4gjolGOOuFcXgWg+3BfLtQKIhyZFQcGK4bkxs=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=KuzcP9KHUikdx5qAEk576vm5tAk2vru7A7CFD/mjtg3T1lRbYudkyWKyecnZ9muic SlFFp0NbhKO6eRrCrVHcPaq3S5jk23Mivc4L8XL7SwcqLzSGt+8JrVnnbxfRwij66f cu7RClSGAYQ1OmFp5fs4L4sNMOgoRRajMHwp+bIs= Received: from smtp56.i.mail.ru (smtp56.i.mail.ru [95.163.41.94]) (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 1730FB8A883 for ; Mon, 27 May 2024 11:52:32 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1730FB8A883 Received: by smtp56.i.mail.ru with esmtpa (envelope-from ) id 1sBW5m-0000000CVPO-1Waa; Mon, 27 May 2024 11:52:31 +0300 Date: Mon, 27 May 2024 11:52:30 +0300 To: Sergey Kaplun Message-ID: References: <6f8a08e1823bfceebb4057207ee2f2bdb7d2d47c.1715776117.git.skaplun@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6f8a08e1823bfceebb4057207ee2f2bdb7d2d47c.1715776117.git.skaplun@tarantool.org> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD92D983CBBFCCE46A6ACC269A17C3537C7FA4B0CD4230405D01313CFAB8367EF908E2BE116634AD74D4D26B379C0D79A922571F2AED9B08C82C99F1961D31CAF81AC6912CE98BD0F49768ACFD3FE3A7A49 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE705B79473340BE836C2099A533E45F2D0395957E7521B51C2CFCAF695D4D8E9FCEA1F7E6F0F101C6778DA827A17800CE7AD3501B5CE9C42E3EA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38B043BF0FB74779F36E0AAD7FD6920FFD3983A1052C813425E1C753058A2466FC1A471835C12D1D9774AD6D5ED66289B5278DA827A17800CE70F3DDF2BBF19B93A9FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C3E478A468B35FE767117882F4460429728AD0CFFFB425014E868A13BD56FB6657D81D268191BDAD3DC09775C1D3CA48CFE1494C00D8047530BA3038C0950A5D36C8A9BA7A39EFB766D91E3A1F190DE8FDBA3038C0950A5D36D5E8D9A59859A8B69FB0157AEC62EB7A76E601842F6C81A1F004C906525384303E02D724532EE2C3F43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7CEB8BE9EE02D59E2D43847C11F186F3C59DAA53EE0834AAEE X-C1DE0DAB: 0D63561A33F958A5FAA3BFC79D0D01155002B1117B3ED696EFC6C6D4743E7653250A03108B67251B823CB91A9FED034534781492E4B8EEAD9CFA8CFAC159CE19BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADBF74143AD284FC7177DD89D51EBB7742424CF958EAFF5D571004E42C50DC4CA955A7F0CF078B5EC49A30900B95165D34AB80C45F81B80D632D1DE45E263624EB4749E5CE8FAC6EE5284FD746886357BC9A1F9CFF47AEB2401D7E09C32AA3244C7540318BA2D7604E4EB7DF677E51682D3E5371765A525A1DEA455F16B58544A2557BDE0DD54B3590965026E5D17F6739C77C69D99B9914278E50E1F0597A6FD5CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojnJlDmFYFlmHeUVj0a7GLbA== X-Mailru-Sender: 7940E2A4EB16C997444464F0EF3AAF24813544B6C4DBD2640578E6996F3834135E6D81F7F82FD64DE2527C969975515CFF9FCECFB8D89CB6C77752E0C033A69E235A20A81F3B0E39AB3C5F247CB2F7F93A5DB60FBEB33A8A0DA7A0AF5A3A8387 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: Maxim Kokryashkin via Tarantool-patches Reply-To: Maxim Kokryashkin Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi, Sergey! Thanks for the patch! Please consider my comments below. On Wed, May 15, 2024 at 03:32:00PM UTC, Sergey Kaplun wrote: > This patch adds Undefined Behaviour Sanitizer [1] support. It enables > all checks except several that are not useful for LuaJIT. Also, it > instruments all known issues to be fixed in future patches (except > `kfold_intop()` since cdata arithmetic relies on integer overflow). > > [1]: https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html > > Resolves tarantool/tarantool#8473 > --- > CMakeLists.txt | 45 ++++++++++++++++++++++++++++++++++++++ > cmake/SetDynASMFlags.cmake | 11 ++++++++++ > src/lj_carith.c | 5 +++++ > src/lj_opt_fold.c | 5 +++++ > src/lj_parse.c | 5 +++++ > src/lj_snap.c | 7 ++++++ > src/lj_strfmt.c | 5 +++++ > 7 files changed, 83 insertions(+) > > diff --git a/CMakeLists.txt b/CMakeLists.txt > index 2355ce17..edf2012f 100644 > --- a/CMakeLists.txt > +++ b/CMakeLists.txt > @@ -300,6 +300,51 @@ if(LUAJIT_USE_ASAN) > ) > endif() > > +option(LUAJIT_USE_UBSAN "Build LuaJIT with UndefinedBehaviorSanitizer" OFF) > +if(LUAJIT_USE_UBSAN) > + # Use all recommendations from the UndefinedBehaviorSanitizer > + # documentation: > + # https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html. > + 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 Why we are not interested in them though? > + # NULL checking is disabled because this is not a UB and > + # raises lots of false-positive fails. > + null > + # 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 > + ) > + if(NOT CMAKE_C_COMPILER_ID STREQUAL "GNU") > + string(JOIN "," UBSAN_IGNORE_OPTIONS > + ${UBSAN_IGNORE_OPTIONS} > + # Not interested in function type mismatch errors. > + function > + ) > + endif() Please drop a comment explaining why this additional configuration is needed. > + AppendFlags(CMAKE_C_FLAGS > + # Enable hints for UndefinedBehaviorSanitizer. > + -DLUAJIT_USE_UBSAN > + # XXX: To get nicer stack traces in error messages. > + -fno-omit-frame-pointer > + # Enable UndefinedBehaviorSanitizer support. > + # This flag enables all supported options (the documentation > + # on cite is not correct about that moment, unfortunately) > + # except float-divide-by-zero. Floating point division by zero > + # behaviour is defined without -ffast-math and uses the > + # IEEE 754 standard on which all NaN tagging is based. > + -fsanitize=undefined > + -fno-sanitize=${UBSAN_IGNORE_OPTIONS} > + # Print a verbose error report and exit the program. > + -fno-sanitize-recover=undefined > + ) > +endif() The whole chunk above is a bit too large to include into the root CMakeLists.txt, so I propose to move it into a separate CMake module. > +