diff --git a/CppCheckSuppressions.txt b/CppCheckSuppressions.txt index 3b12198ba..6d92aadf2 100644 --- a/CppCheckSuppressions.txt +++ b/CppCheckSuppressions.txt @@ -5,8 +5,5 @@ // config of cpp checks needs more includes missingInclude -// Ignore warnings from third parties -*:*/third_party/* - // Ignore Lex and Yacc defects *:*/event_parser/* diff --git a/app/base-env-alpine/Dockerfile b/app/base-env-alpine/Dockerfile index 0517c346e..1b7f4864c 100644 --- a/app/base-env-alpine/Dockerfile +++ b/app/base-env-alpine/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.17.2 +FROM alpine:3.18.0 ARG COMPILER="gcc" ENV CC=gcc ENV CXX=g++ @@ -56,11 +56,11 @@ SHELL ["/bin/bash", "-c"] # Provides the llvm-symbolizer (better debug information in case of sanitizer issue) ENV PATH="/usr/lib/llvm-${CLANG_VERSION}/bin/:$PATH" -### Alpine has cmake 3.23 +### Alpine has newer cmake -# Ninja build 1.10.2 -RUN VERSION="1.10.2" \ - && SHA256="ce35865411f0490368a8fc383f29071de6690cbadc27704734978221f25e2bed" \ +# Ninja build 1.11.1 +RUN VERSION="1.11.1" \ + && SHA256="31747ae633213f1eda3842686f83c2aa1412e0f5691d1c14dbbcc67fe7400cea" \ && curl -LO https://github.com/ninja-build/ninja/archive/refs/tags/v${VERSION}.tar.gz \ && (printf "${SHA256} v${VERSION}.tar.gz" | sha256sum -c) \ && tar xvfz v${VERSION}.tar.gz \ @@ -73,9 +73,9 @@ RUN VERSION="1.10.2" \ ## Alpine has cppcheck 2.8.1-r0 # C++ json library (used for test purpose) -RUN VERSION="3.10.5" \ +RUN VERSION="3.11.2" \ && curl -LO https://github.com/nlohmann/json/releases/download/v${VERSION}/json.tar.xz \ - && SHA256="344be97b757a36c5b180f1c8162f6c5f6ebd760b117f6e64b77866e97b217280" \ + && SHA256="8c4b26bf4b422252e13f332bc5e388ec0ab5c3443d24399acb675e68278d341f" \ && (printf "${SHA256} json.tar.xz" | sha256sum -c) \ && tar xf json.tar.xz \ && cd json \ @@ -86,9 +86,9 @@ RUN VERSION="3.10.5" \ && rm -rf json json.tar.xz # Google benchmark -RUN VERSION="1.6.1" \ +RUN VERSION="1.8.2" \ && curl -LO "https://github.com/google/benchmark/archive/refs/tags/v${VERSION}.tar.gz" \ - && SHA256="6132883bc8c9b0df5375b16ab520fac1a85dc9e4cf5be59480448ece74b278d4" \ + && SHA256="2aab2980d0376137f969d92848fbb68216abb07633034534fc8c65cc4e7a0e93" \ && (printf "${SHA256} v${VERSION}.tar.gz" | sha256sum -c) \ && tar xf v${VERSION}.tar.gz \ && cd benchmark-${VERSION} \ diff --git a/app/base-env/Dockerfile b/app/base-env/Dockerfile index bd7ea1979..fb3ad31b2 100644 --- a/app/base-env/Dockerfile +++ b/app/base-env/Dockerfile @@ -7,6 +7,10 @@ FROM ubuntu:${UBUNTU_VERSION}.04 as base ARG UBUNTU_VERSION ENV OS_IDENTIFIER="UB${UBUNTU_VERSION}" +FROM base AS base-23 +ENV GCC_VERSION=13 +ENV CLANG_VERSION=16 + FROM base AS base-22 ENV GCC_VERSION=12 ENV CLANG_VERSION=15 @@ -62,6 +66,7 @@ RUN apt-get update \ ssh-client \ subversion \ unzip \ + valgrind \ wget \ zlib1g-dev @@ -91,11 +96,11 @@ RUN VERSION="3.22.2" \ && tar --no-same-owner -C /usr/local --strip-components=1 -xf ${TAR_NAME} \ && rm ${TAR_NAME} -# Ninja build 1.10.2 -RUN VERSION="1.10.2" \ - && SHA256="ce35865411f0490368a8fc383f29071de6690cbadc27704734978221f25e2bed" \ +# Ninja build 1.11.1 +RUN VERSION="1.11.1" \ + && SHA256="31747ae633213f1eda3842686f83c2aa1412e0f5691d1c14dbbcc67fe7400cea" \ && curl -LO https://github.com/ninja-build/ninja/archive/refs/tags/v${VERSION}.tar.gz \ - && (printf "${SHA256} v${VERSION}.tar.gz" | sha256sum --check --strict --status) \ + && (printf "${SHA256} v${VERSION}.tar.gz" | sha256sum -c) \ && tar xvfz v${VERSION}.tar.gz \ && cd ninja-${VERSION} \ && cmake -Bbuild-cmake \ @@ -146,36 +151,24 @@ RUN VERSION="3.10.5" \ # Command line includes a change # - in python which is missing on ubuntu 20.04, use python 3 instead # - in options_test.cc to fix a clang build issue (fixed after 1.7.1) -RUN VERSION="1.7.1" \ +RUN VERSION="1.8.2" \ && curl -LO "https://github.com/google/benchmark/archive/refs/tags/v${VERSION}.tar.gz" \ - && SHA256="6430e4092653380d9dc4ccb45a1e2dc9259d581f4866dc0759713126056bc1d7" \ + && SHA256="2aab2980d0376137f969d92848fbb68216abb07633034534fc8c65cc4e7a0e93" \ && (printf "${SHA256} v${VERSION}.tar.gz" | sha256sum --check --strict --status) \ && tar xf v${VERSION}.tar.gz \ && pushd benchmark-${VERSION} \ && { command -v python > /dev/null || { ln -s /usr/bin/python3 python && export PATH=$PWD:$PATH; }; } \ - && sed -i 's/^\s*size_t actual_iterations = 0;\s*$/ for (auto _ : state) {}/' ./test/options_test.cc \ - && sed -i 's/^\s*for (auto _ : state) ++actual_iterations;\s*$//' ./test/options_test.cc \ && cmake -DCMAKE_BUILD_TYPE=Release -DBENCHMARK_USE_BUNDLED_GTEST=OFF -GNinja -S . -B "build" \ && cmake --build "build" --target install \ && popd \ && rm -rf benchmark-${VERSION} v${VERSION}.tar.gz -# Valgrind with dwarf 5 support -RUN VERSION="3.21.0" \ - && curl -LO "https://sourceware.org/pub/valgrind/valgrind-${VERSION}.tar.bz2" \ - && SHA1="817d769743d278b5d07526e85115082054e9bf9c" \ - && (printf "${SHA1} valgrind-${VERSION}.tar.bz2" | sha1sum --check --strict --status) \ - && tar xvf valgrind-${VERSION}.tar.bz2 \ - && pushd valgrind-${VERSION} \ - && ./configure --prefix /usr/local \ - && make -j 4 \ - && make install \ - && valgrind --version \ - && popd \ - && rm -Rf valgrind-${VERSION} valgrind-${VERSION}.tar.bz2 - # Install cmake_format -RUN pip3 install cmake_format +RUN if [ "$UBUNTU_VERSION" -eq 23 ]; then \ + pip3 install --break-system-packages cmake-format; \ + else \ + pip3 install cmake-format; \ + fi # A specific user is required to get access to perf event ressources. # This enables unit testing using perf-event ressources diff --git a/include/lib/allocation_tracker.hpp b/include/lib/allocation_tracker.hpp index 567dab62e..4ced70a99 100644 --- a/include/lib/allocation_tracker.hpp +++ b/include/lib/allocation_tracker.hpp @@ -26,7 +26,7 @@ struct TrackerThreadLocalState { int64_t remaining_bytes; // remaining allocation bytes until next sample bool remaining_bytes_initialized; // false if remaining_bytes is not // initialized - ddprof::span stack_bounds; + ddprof::span stack_bounds; pid_t tid; // cache of tid bool reentry_guard; // prevent reentry in AllocationTracker (eg. when diff --git a/include/lib/saveregisters.hpp b/include/lib/saveregisters.hpp index 0f0f747c5..5e0f05924 100644 --- a/include/lib/saveregisters.hpp +++ b/include/lib/saveregisters.hpp @@ -27,10 +27,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "perf_archmap.hpp" #include "span.hpp" +#include + #if defined(__x86_64__) DDPROF_NOINLINE __attribute__((naked)) void - save_registers(ddprof::span); + save_registers(ddprof::span); #elif defined(__aarch64__) diff --git a/include/span.hpp b/include/span.hpp index c7c223f91..00abf9e04 100644 --- a/include/span.hpp +++ b/include/span.hpp @@ -5,7 +5,7 @@ #pragma once -#if __cpp_lib_span +#if __cplusplus >= 202002L # include diff --git a/include/tempfile.hpp b/include/tempfile.hpp index 3df1a58c6..f44a474fe 100644 --- a/include/tempfile.hpp +++ b/include/tempfile.hpp @@ -14,10 +14,9 @@ namespace ddprof { DDRes get_or_create_temp_file(std::string_view prefix, - ddprof::span data, mode_t mode, + span data, mode_t mode, std::string &path); -DDRes create_temp_file(std::string_view prefix, - ddprof::span data, mode_t mode, - std::string &path); +DDRes create_temp_file(std::string_view prefix, span data, + mode_t mode, std::string &path); } // namespace ddprof diff --git a/src/ddprof_cli.cc b/src/ddprof_cli.cc index 5a7056f98..2b0ca041a 100644 --- a/src/ddprof_cli.cc +++ b/src/ddprof_cli.cc @@ -3,6 +3,13 @@ // developed at Datadog (https://www.datadoghq.com/). Copyright 2021-Present // Datadog, Inc. +// gcc 13 issue - remove FORTIFY_SOURCE +//clang-format off +// /usr/include/fortify/stdio.h:73:28: error: inlining failed in call to 'always_inline' 'vsnprintf': function body can be overwritten at link time +// 73 | _FORTIFY_FN(vsnprintf) int vsnprintf(char * _FORTIFY_POS0 __s, size_t __n, +//clang-format on +#undef _FORTIFY_SOURCE + #include "ddprof_cli.hpp" #include "CLI/CLI11.hpp" diff --git a/src/ddprof_cpumask.cc b/src/ddprof_cpumask.cc index f6860f341..fbaa327ac 100644 --- a/src/ddprof_cpumask.cc +++ b/src/ddprof_cpumask.cc @@ -5,6 +5,7 @@ #include "ddprof_cpumask.hpp" +#include #include #include #include diff --git a/src/exe/main.cc b/src/exe/main.cc index 2a0709af8..81305f2d8 100644 --- a/src/exe/main.cc +++ b/src/exe/main.cc @@ -127,11 +127,11 @@ static DDRes get_library_path(TempFileHolder &libdd_profiling_path, } if (profiling_path.empty()) { - DDRES_CHECK_FWD(get_or_create_temp_file( + DDRES_CHECK_FWD(ddprof::get_or_create_temp_file( k_libdd_profiling_embedded_name, ddprof::as_bytes(ddprof::span{_binary_libdd_profiling_embedded_so_start, _binary_libdd_profiling_embedded_so_end}), - 0644, profiling_path)); + mode_t(0644), profiling_path)); libdd_profiling_path = TempFileHolder{profiling_path, false}; } else { libdd_profiling_path = TempFileHolder{profiling_path, false}; @@ -139,7 +139,7 @@ static DDRes get_library_path(TempFileHolder &libdd_profiling_path, #ifdef DDPROF_USE_LOADER if (loader_path.empty()) { - DDRES_CHECK_FWD(get_or_create_temp_file( + DDRES_CHECK_FWD(ddprof::get_or_create_temp_file( k_libdd_loader_name, ddprof::as_bytes(ddprof::span{_binary_libdd_loader_so_start, _binary_libdd_loader_so_end}), @@ -151,7 +151,6 @@ static DDRes get_library_path(TempFileHolder &libdd_profiling_path, #else (void)libdd_loader_path; #endif - return {}; } diff --git a/src/lib/savecontext.cc b/src/lib/savecontext.cc index 748a7be49..e1b90ff08 100644 --- a/src/lib/savecontext.cc +++ b/src/lib/savecontext.cc @@ -40,13 +40,14 @@ DDPROF_NOINLINE ddprof::span retrieve_stack_bounds() { static DDPROF_NO_SANITIZER_ADDRESS size_t save_stack(ddprof::span stack_bounds, const std::byte *stack_ptr, ddprof::span buffer) { + const std::byte *stack_ptr_end = (stack_bounds.data() + stack_bounds.size()); // Safety check to ensure we are not in a fiber using a different stack - if (!(stack_ptr >= stack_bounds.begin() && stack_ptr < stack_bounds.end())) { + if (!(stack_ptr >= stack_bounds.data() && stack_ptr < stack_ptr_end)) { return 0; } // take the min of current stack size and requested stack sample size~ - int64_t saved_stack_size = std::min(static_cast(buffer.size()), - stack_bounds.end() - stack_ptr); + int64_t saved_stack_size = + std::min(static_cast(buffer.size()), stack_ptr_end - stack_ptr); if (saved_stack_size <= 0) { return 0; diff --git a/src/tempfile.cc b/src/tempfile.cc index fe2d28fca..27b670a8e 100644 --- a/src/tempfile.cc +++ b/src/tempfile.cc @@ -18,7 +18,7 @@ namespace ddprof { DDRes get_or_create_temp_file(std::string_view prefix, - ddprof::span data, mode_t mode, + span data, mode_t mode, std::string &path) { unsigned char digest[20]; char str_digest[41]; @@ -45,9 +45,8 @@ DDRes get_or_create_temp_file(std::string_view prefix, return {}; } -DDRes create_temp_file(std::string_view prefix, - ddprof::span data, mode_t mode, - std::string &path) { +DDRes create_temp_file(std::string_view prefix, span data, + mode_t mode, std::string &path) { std::error_code ec; auto template_str = std::string{std::filesystem::temp_directory_path(ec) / prefix} +