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 2D967A653D3; Tue, 26 Mar 2024 11:36:55 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 2D967A653D3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1711442215; bh=bFPANx9rhVGSY+7H4Y4cC4VRc+sgk2sIwEhrN8I38o0=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=FAeJVM0dZ/KtEdWbeLUQ/FwehMAwo1DWNlZ5XkpkM0t7FqvLKkriBa+QBtCuCKrfO bJyur7hn8dmicDsnSakEhaeCcwwaD3hZ9RlErGzS6pCyCy7alUeiK4v4ssvxlWHcGT jChTH5CinHpzrDq+e5lFszp8F8wgKOOOuNyPmEEw= Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 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 16EE4A653D3 for ; Tue, 26 Mar 2024 11:34:32 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 16EE4A653D3 Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-513cfc93f4eso5641298e87.3 for ; Tue, 26 Mar 2024 01:34:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711442071; x=1712046871; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8Twi/d4v2IEXS9WQhsSdDWUq4ra1sNnhroRRDb+KAPc=; b=LJdNwx4IzOnZXvDkd7AYtNYiadeSGD1Dmk5B9paNCVtdR7x+6QtYERAmyO3nYpIjkO w5pOPwxYkc0yot6bB504sTsy5BQd6S0URMmLurqXHyIgBfcnS7t6nR+xl+B0x7zU1qXu CLPsHQgutcg7N7f/0sKddUiAKbdkvUNCjyPKMfH+4kQg12d0DqhclRGzlR64Ygnfuve1 3Oa8ogSl2uOEkfDj+xmWNSoO9N26NBm1OFBuPJibxI/JIEp4o7ekAtw5bF7mgWzG7n6l rBA/MmDqQbG2QjvbCD6s0GKEr97HsF70/kYxyqOU0qJg5MARw+gtl8by09EzDiXmcYbv Wr1w== X-Gm-Message-State: AOJu0Yx7pogcxfQyL2H6D3vk1eoTEfO6x8+iDMtbucUCCBHRIBf5vgat dMReZvyU6zDLkmPU+bhRgMg5A63aqDYf+3lrNI6aHfY46Pm3012CwOkkOY98Gi4= X-Google-Smtp-Source: AGHT+IHIA78RY+qrO4hq67Id2p3Q6GiATn2Y59iJFxrytfRW6p4V7EzZOUhUqSVeqcH31rHnPOfcaw== X-Received: by 2002:a05:6512:10d1:b0:515:b9fe:dd94 with SMTP id k17-20020a05651210d100b00515b9fedd94mr456517lfg.25.1711442071038; Tue, 26 Mar 2024 01:34:31 -0700 (PDT) Received: from pony.. ([5.181.62.126]) by smtp.gmail.com with ESMTPSA id y11-20020a056512044b00b005159c7939basm1434099lfk.185.2024.03.26.01.34.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 01:34:30 -0700 (PDT) To: tarantool-patches@dev.tarantool.org, Sergey Kaplun , Maxim Kokryashkin Date: Tue, 26 Mar 2024 11:33:31 +0300 Message-Id: <19e2e200fa5da4d6fb6875e599b9f8bd0a0048b9.1711441864.git.sergeyb@tarantool.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH luajit 5/6] test: fix lj-802-panic-at-mcode-protfail GCC+ASan 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" From: Sergey Kaplun The aforementioned test uses `LD_PRELOAD` to mock the system call to `mprotect()`. The GCC implementation of libasan requires that the ASan library go first in the `LD_PRELOAD` list. This patch tweaks the behaviour to avoid failure of the test. OTOH, this patch intorduces warnings related to the libc leaks for a couple of tests, but they are not treated as test failures. This should be fixed by target setting LD_PRELOAD only for necessary tests when we start using CTest instead of `prove`. Part of tarantool/tarantool#9656 Co-authored-by: Sergey Bronnikov --- test/tarantool-tests/CMakeLists.txt | 15 +++++++++++++++ test/tarantool-tests/utils/exec.lua | 14 ++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/test/tarantool-tests/CMakeLists.txt b/test/tarantool-tests/CMakeLists.txt index e6d12984..35bcc5ef 100644 --- a/test/tarantool-tests/CMakeLists.txt +++ b/test/tarantool-tests/CMakeLists.txt @@ -110,6 +110,21 @@ else() list(APPEND LUA_TEST_ENV_MORE LD_LIBRARY_PATH=${LD_LIBRARY_PATH}) endif() +# Some tests use `LD_PRELOAD` to mock system calls (like +# overwrites +# `mprotect()`. When compiling with ASan support under GCC, it is +# required that the ASan library go first in the `LD_PRELOAD` +# list. Set it manually, test will append it to the executed +# process. +# See also: https://github.com/tarantool/tarantool/issues/9656. +if(LUAJIT_USE_ASAN AND CMAKE_C_COMPILER_ID STREQUAL "GNU") + # FIXME: After using CTest instead of `prove` we should set this + # environment variable only for the corresponding tests to avoid + # warnings from the libc and etc. + LibRealPath(LIB_ASAN libasan.so) + list(APPEND LUA_TEST_ENV_MORE LD_PRELOAD=${LIB_ASAN}) +endif() + # LUA_CPATH and LD_LIBRARY_PATH variables and also dependencies # list with libraries are set in scope of BuildTestLib macro. add_custom_command(TARGET tarantool-tests diff --git a/test/tarantool-tests/utils/exec.lua b/test/tarantool-tests/utils/exec.lua index 48a08ba5..49f8ef06 100644 --- a/test/tarantool-tests/utils/exec.lua +++ b/test/tarantool-tests/utils/exec.lua @@ -24,6 +24,20 @@ local function makeenv(tabenv) if tabenv == nil then return '' end local flatenv = {} for var, value in pairs(tabenv) do + if var == 'LD_PRELOAD' then + -- XXX: For ASan used by GCC, the ASan library should go + -- first in the `LD_PRELOAD` list, or we get the error: + -- "ASan runtime does not come first in initial library + -- list;". + -- See https://github.com/tarantool/tarantool/issues/9656 + -- for details. + -- So, prepend the given library from `LD_PRELOAD` to the + -- start of the list. The separator may be ':' or ' ', see + -- man ld.so(8).so. Use ':' as the most robust. + local ld_preload = os.getenv('LD_PRELOAD') + local ld_preload_prefix = ld_preload and ld_preload .. ':' or '' + value = ld_preload_prefix .. value + end table.insert(flatenv, ('%s=%s'):format(var, value)) end return table.concat(flatenv, ' ') -- 2.34.1