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 ECD30DD98D0; Mon, 2 Dec 2024 16:53:14 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org ECD30DD98D0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1733147595; bh=arOq6Coaa7UkBg9/jwbbQYfhJhLEi/AO7EQNI7j09Yk=; h=To:Cc:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=GjXNYvDUGKFtAPVJ0p0ulK9TN470h16L9KkpxdyaAx6S5iY9w365CDQ8Jg0hHf+rU Rln0acK5QgqtvSFhDzF99jFjj9GGknaVw9MNkdFXb6Nbixh5dnbiGm+epe9X9UiOIY MnOw/mC/iuYC4zXxLYHg4bwuD3OtYmDNRjmjr64w= Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (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 B1FFCDE9352 for ; Mon, 2 Dec 2024 16:52:14 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B1FFCDE9352 Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-53df1d1b6e8so4485072e87.1 for ; Mon, 02 Dec 2024 05:52:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733147534; x=1733752334; 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=gGlX17NxmAS6gkgppPOzLfG0mkPx0cNjWLM8JKxzv+s=; b=nW/lcwrT50YTcpA0Uwry0up90X2W0jRpXs5oJATLMhzm0WYVXUK0Ra5YyDeekeG3jy JPdtaMysmH2QUt4iyoK6QUk5FTVNndp8iaf7jHQwwHU+6y8vwBQZSLZ/sKiWz9KpfZHX YmjsBEz1cJlyh7klkOsKFGxZoBBQLE3XxyFDebl4odd2oJJEj24OFCIY8qyFiS/KoKnG HFFSGJjqza0vz4pIky4nxsrDBSF1IIvDhtldH8ktv+74OaLeJrTH/5KhQDl67kloGbL1 QhVpn3avfHM2PntwsBY0k/m+/SV0Z7sGf2xVckEqa1FOLjKsPoxLY7+KIqsryxeTBobx D9vQ== X-Gm-Message-State: AOJu0Yy8x6mw5iChyPtK3MJtrWccB7naHggaBsKWFRPiLDngh8k8TCay AyQEH4xkyOWodDqWc6qjmni+7Mo8EhGV5U2ljhfpWjzy/wNAOOK2TKsMSXx1 X-Gm-Gg: ASbGncs9jGS6ac6Jcl7S60+pIHfGnRiUgMB7SdXSwSLLskPqs7N4SsxX7qARktvqicd iLFx8OUOuZ9kwrnkMv1KNQpODZALRUdjj3ilUHSeZTDfcmAdE9Jtam23qsi7Ewi5XhQR0/SuR/N DOZ7JtEmzn1tSur76ZMf2cJkZpvKdAq08qk2K5VsNFrTGKMLk2JtE1TyILvEWhdb97SICIn5Y5E Lcq7aDLDd3QsWfPu1eu7o0b3Eulwr5oD+PVX6CnOXikqYAd++K3rZ5AA+IgKgwZixhh6qSK2DLJ rj4= X-Google-Smtp-Source: AGHT+IFuYb2NHg1pfet7In17JWzKX/IcDWY7eSdnaX6qsWQvKxn7wVMSErpS0wYqHwKpzx9dcDpWxA== X-Received: by 2002:a05:6512:2398:b0:53d:e7b6:c6ec with SMTP id 2adb3069b0e04-53df010493emr8029162e87.41.1733147533649; Mon, 02 Dec 2024 05:52:13 -0800 (PST) Received: from mandesero.www.tendawifi.com ([85.89.127.21]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53df6496a10sm1455125e87.203.2024.12.02.05.52.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2024 05:52:13 -0800 (PST) To: tarantool-patches@dev.tarantool.org, skaplun@tarantool.org, m.kokryashkin@tarantool.org Cc: Maksim Tiushev Date: Mon, 2 Dec 2024 13:52:11 +0000 Message-Id: <20241202135211.3714-3-mandesero@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241202135211.3714-1-mandesero@gmail.com> References: <20241202135211.3714-1-mandesero@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v4 luajit 2/2] ci: add Valgrind testing workflow 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: mandesero--- via Tarantool-patches Reply-To: mandesero@gmail.com Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" From: Maksim Tiushev This patch adds CI testing with Valgrind in three scenarios: - Full checks enabled. - No leak checks, with memory fill set to `--malloc-fill=0x00` and `--free-fill=0x00`. - No leak checks, with memory fill set to `--malloc-fill=0xFF` and `--free-fill=0xFF`. The use of `0x00` and `0xFF` for memory fill helps to detect dirty reads. `0x00` mimics zero-initialized memory, which can mask some uninitialized memory usage. `0xFF` fills memory with a non-zero values to make such errors easier to spot. Closes tarantool/tarantool#3705 --- .github/actions/setup-valgrind/README.md | 12 +++ .github/actions/setup-valgrind/action.yml | 12 +++ .github/workflows/valgrind-testing.yaml | 99 +++++++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 .github/actions/setup-valgrind/README.md create mode 100644 .github/actions/setup-valgrind/action.yml create mode 100644 .github/workflows/valgrind-testing.yaml diff --git a/.github/actions/setup-valgrind/README.md b/.github/actions/setup-valgrind/README.md new file mode 100644 index 00000000..e7d66a3a --- /dev/null +++ b/.github/actions/setup-valgrind/README.md @@ -0,0 +1,12 @@ +# Setup environment for Valgrind on Linux + +Action setups the environment on Linux runners (install requirements, setup the +workflow environment, etc) for testing with Valgrind. + +## How to use Github Action from Github workflow + +Add the following code to the running steps before LuaJIT configuration: +``` +- uses: ./.github/actions/setup-valgrind + if: ${{ matrix.OS == 'Linux' }} +``` \ No newline at end of file diff --git a/.github/actions/setup-valgrind/action.yml b/.github/actions/setup-valgrind/action.yml new file mode 100644 index 00000000..5c11fdaa --- /dev/null +++ b/.github/actions/setup-valgrind/action.yml @@ -0,0 +1,12 @@ +name: Setup CI environment with Valgrind on Linux +description: Extend setup-linux with Valgrind installation + +runs: + using: composite + steps: + - name: Setup CI environment (Linux) + uses: ./.github/actions/setup-linux + - name: Install Valgrind + run: | + apt -y install valgrind + shell: bash diff --git a/.github/workflows/valgrind-testing.yaml b/.github/workflows/valgrind-testing.yaml new file mode 100644 index 00000000..50d01a45 --- /dev/null +++ b/.github/workflows/valgrind-testing.yaml @@ -0,0 +1,99 @@ +name: Valgrind testing + +on: + push: + branches-ignore: + - '**-notest' + - 'upstream-**' + tags-ignore: + - '**' + +concurrency: + # An update of a developer branch cancels the previously + # scheduled workflow run for this branch. However, the default + # branch, and long-term branch (tarantool/release/2.11, + # tarantool/release/2.10, etc) workflow runs are never canceled. + # + # We use a trick here: define the concurrency group as 'workflow + # run ID' + # 'workflow run attempt' because it is a unique + # combination for any run. So it effectively discards grouping. + # + # XXX: we cannot use `github.sha` as a unique identifier because + # pushing a tag may cancel a run that works on a branch push + # event. + group: ${{ startsWith(github.ref, 'refs/heads/tarantool/') + && format('{0}-{1}', github.run_id, github.run_attempt) + || format('{0}-{1}', github.workflow, github.ref) }} + cancel-in-progress: true + +jobs: + test-valgrind: + strategy: + fail-fast: false + matrix: + # XXX: Let's start with only Linux/x86_64 + # We don't test on Linux/ARM64 because the address returned by the + # system allocator may exceed 47 bits. As a result, we are unable to + # allocate memory for `lua_State`. Therefore, testing on this platform + # is currently disabled. + BUILDTYPE: [Debug, Release] + VALGRIND_SCENARIO: [full, malloc-free-fill-0x00, malloc-free-fill-0xff] + include: + - BUILDTYPE: Debug + CMAKEFLAGS: -DCMAKE_BUILD_TYPE=Debug -DLUA_USE_ASSERT=ON -DLUA_USE_APICHECK=ON + - BUILDTYPE: Release + CMAKEFLAGS: -DCMAKE_BUILD_TYPE=RelWithDebInfo + - VALGRIND_SCENARIO: full + VALGRIND_OPTS: --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --error-exitcode=1 + JOB_POSTFIX: "leak-check: full" + # The use of `0x00` and `0xFF` for memory fill helps to detect dirty + # reads. `0x00` mimics zero-initialized memory, which can mask some + # uninitialized memory usage. `0xFF` fills memory with a non-zero + # values to make such errors easier to spot. + - VALGRIND_SCENARIO: malloc-free-fill-0x00 + VALGRIND_OPTS: --leak-check=no --malloc-fill=0x00 --free-fill=0x00 --verbose --error-exitcode=1 + JOB_POSTFIX: "malloc/free-fill: 0x00" + - VALGRIND_SCENARIO: malloc-free-fill-0xff + VALGRIND_OPTS: --leak-check=no --malloc-fill=0xff --free-fill=0xff --verbose --error-exitcode=1 + JOB_POSTFIX: "malloc/free-fill: 0xff" + runs-on: [self-hosted, regular, Linux, x86_64] + name: > + LuaJIT with Valgrind (Linux/x86_64) + ${{ matrix.BUILDTYPE }} + CC: gcc + GC64:ON SYSMALLOC:ON + ${{ matrix.JOB_POSTFIX }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: recursive + - name: setup Linux for Valgrind + uses: ./.github/actions/setup-valgrind + - name: configure + # XXX: LuaJIT configuration requires a couple of tweaks: + # LUAJIT_USE_SYSMALLOC=ON: Unfortunately, internal LuaJIT + # memory allocator is not instrumented yet, so to find + # any memory errors it's better to build LuaJIT with + # system provided memory allocator (i.e. run CMake + # configuration phase with -DLUAJIT_USE_SYSMALLOC=ON). + # For more info, see root CMakeLists.txt. + # LUAJIT_ENABLE_GC64=ON: LUAJIT_USE_SYSMALLOC cannot be + # enabled on x64 without GC64, since realloc usually + # doesn't return addresses in the right address range. + # For more info, see root CMakeLists.txt. + env: + VALGRIND_OPTS: ${{ matrix.VALGRIND_OPTS }} + run: > + cmake -S . -B ${{ env.BUILDDIR }} + -G Ninja + ${{ matrix.CMAKEFLAGS }} + -DLUAJIT_USE_VALGRIND=ON + -DLUAJIT_ENABLE_GC64=ON + -DLUAJIT_USE_SYSMALLOC=ON + - name: build + run: cmake --build . --parallel + working-directory: ${{ env.BUILDDIR }} + - name: test + run: cmake --build . --parallel --target LuaJIT-test + working-directory: ${{ env.BUILDDIR }} -- 2.34.1