Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Adding CTest memcheck to CodeBuild #4776

Merged
merged 33 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
21f979a
ci: add ctest memcheck test
Sep 6, 2024
13f270b
ci: add valgrind options into `CMakeLists.txt`
Sep 9, 2024
d1c197d
ci: add CTest memcheck for codebuild
Sep 12, 2024
ff78b5d
ci: adjusting valgrind suppressions and valgrind setup
Sep 16, 2024
c02588a
ci: modify valgrind suppressions
Sep 16, 2024
d4d0d52
ci: fixing valgrind suppressions and reformat valgrind yml
Sep 17, 2024
76aa3b4
ci: reformat buildspec_valgrind.yml
Sep 17, 2024
8e3b17c
ci: address PR comments
Sep 17, 2024
757d5de
Merge branch 'main' into memcheck-ci
boquan-fang Sep 17, 2024
654a9e0
ci: address PR comments
Sep 17, 2024
4f3b543
ci: address PR comments
Sep 17, 2024
b6c7fb6
ci: address PR comments
Sep 17, 2024
eea54eb
ci: address PR comments
Sep 17, 2024
0abf3fc
Merge branch 'main' into memcheck-ci
boquan-fang Sep 18, 2024
93b4f86
ci: change `CMakeLists.txt` comments
Sep 18, 2024
fb8ef64
ci: address PR comments
Sep 18, 2024
f899747
ci: address PR comments
Sep 18, 2024
5b85e3b
Merge branch 'main' into memcheck-ci
boquan-fang Sep 18, 2024
f0f08c6
ci: address PR comments
Sep 18, 2024
3bab3bb
ci: adjust indentations for valgrind default options
Sep 19, 2024
b0f74a1
ci: adjust `valgrind.suppressions`
Sep 19, 2024
9b219e5
Merge branch 'main' into memcheck-ci
boquan-fang Sep 19, 2024
47147f1
ci: modify links in comments
Sep 19, 2024
991b2a9
ci: add docker image
Sep 19, 2024
2f45d5b
Merge branch 'main' into memcheck-ci
boquan-fang Sep 20, 2024
fdeac70
ci: adding display error script to CI
Sep 20, 2024
e74c1d5
ci: address PR comments
Sep 24, 2024
8ebb050
Merge branch 'main' into memcheck-ci
boquan-fang Sep 27, 2024
e7ab1ff
ci: correct Valgrind and buildspec setting
Sep 27, 2024
efe6477
ci: address PR comments
Oct 1, 2024
6db76f4
ci: address PR comments
Oct 1, 2024
0e4774b
Update tests/unit/valgrind.suppressions
boquan-fang Oct 1, 2024
29b6da3
Merge branch 'main' into memcheck-ci
boquan-fang Oct 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,37 @@ set(INSTALL_CMAKE_DIR lib/cmake CACHE PATH "Installation directory for cmake fil

set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE)

set(CTEST_MEMORYCHECK_TYPE "Valgrind")
boquan-fang marked this conversation as resolved.
Show resolved Hide resolved

set(MEMORYCHECK_COMMAND_OPTIONS_REGULAR " \
boquan-fang marked this conversation as resolved.
Show resolved Hide resolved
--leak-check=full \
--leak-resolution=high \
--trace-children=yes \
--run-libc-freeres=no \
-q --error-exitcode=123 \
--error-limit=no \
--num-callers=40 \
--undef-value-errors=no \
--suppressions=valgrind.suppressions")

set(MEMORYCHECK_COMMAND_OPTIONS_PENDANTIC " \
--leak-check=full \
--leak-resolution=high \
--trace-children=yes \
--run-libc-freeres=no \
-q --error-exitcode=123 \
--error-limit=no \
--num-callers=40 \
--undef-value-errors=no \
--errors-for-leak-kinds=all \
--suppressions=valgrind.suppressions")

if ($ENV{S2N_LIBCRYPTO} MATCHES "openssl-1.1.1")
boquan-fang marked this conversation as resolved.
Show resolved Hide resolved
set(MEMORYCHECK_COMMAND_OPTIONS ${MEMORYCHECK_COMMAND_OPTIONS_PENDANTIC})
else()
set(MEMORYCHECK_COMMAND_OPTIONS ${MEMORYCHECK_COMMAND_OPTIONS_REGULAR})
endif()

# These Version numbers are for major updates only- we won't track minor/patch updates here.
set(VERSION_MAJOR 1)
set(VERSION_MINOR 0)
Expand Down
54 changes: 54 additions & 0 deletions codebuild/spec/buildspec_valgrind.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use
# this file except in compliance with the License. A copy of the License is
# located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing permissions and
# limitations under the License.
version: 0.2

batch:
build-list:
- identifier: gcc_awslc
env:
compute-type: BUILD_GENERAL1_LARGE
variables:
S2N_LIBCRYPTO: awslc
COMPILER: gcc
- identifier: gcc_openssl_3_0
env:
compute-type: BUILD_GENERAL1_LARGE
variables:
S2N_LIBCRYPTO: openssl-3.0
COMPILER: gcc
boquan-fang marked this conversation as resolved.
Show resolved Hide resolved

phases:
pre_build:
commands:
- |
if [ -d "third-party-src" ]; then
cd third-party-src;
fi
lrstewart marked this conversation as resolved.
Show resolved Hide resolved
- /usr/bin/$COMPILER --version
build:
on-failure: ABORT
commands:
- |
cmake . -Bbuild \
-DCMAKE_C_COMPILER=/usr/bin/$COMPILER \
-DCMAKE_PREFIX_PATH=/usr/local/$S2N_LIBCRYPTO \
-DCMAKE_BUILD_TYPE=RelWithDebInfo
- cmake --build ./build -- -j $(nproc)
post_build:
on-failure: ABORT
commands:
- |
S2N_VALGRIND=1 CTEST_PARALLEL_LEVEL=$(nproc) \
CTEST_OUTPUT_ON_FAILURE=1 ctest -T memcheck \
--test-dir build ARGS="-output-on-failure"
boquan-fang marked this conversation as resolved.
Show resolved Hide resolved
41 changes: 40 additions & 1 deletion tests/unit/valgrind.suppressions
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,46 @@
fun:pthread_create@@GLIBC_2.2.5
fun:main
}

# Append valgrind suppression for ubuntu22
boquan-fang marked this conversation as resolved.
Show resolved Hide resolved
{
pthread_false_positive_ubuntu22
boquan-fang marked this conversation as resolved.
Show resolved Hide resolved
Memcheck:Leak
match-leak-kinds: possible
fun:calloc
fun:calloc
fun:allocate_dtv
fun:_dl_allocate_tls
fun:allocate_stack
fun:pthread_create@@GLIBC_2.34
...
fun:main
}
# Backtrace might generate false positives with its _dl_open function call: https://stackoverflow.com/questions/78525668/egl-memory-leak
boquan-fang marked this conversation as resolved.
Show resolved Hide resolved
{
stacktrace_suppression
Memcheck:Leak
match-leak-kinds: possible
fun:malloc
fun:malloc
fun:_dlfo_mappings_segment_allocate
fun:_dl_find_object_update_1
fun:_dl_find_object_update
fun:dl_open_worker_begin
fun:_dl_catch_exception
fun:dl_open_worker
fun:_dl_catch_exception
fun:_dl_open
fun:do_dlopen
fun:_dl_catch_exception
fun:_dl_catch_error
fun:dlerror_run
fun:__libc_dlopen_mode
fun:__libc_unwind_link_get
fun:__libc_unwind_link_get
fun:backtrace
...
fun:main
}
# TODO: fix the pedantic leak errors from s2n_fork_generation_number_test
{
ignore_s2n_fork_generation_number_test
Expand Down
Loading