DPDK patches and discussions
 help / color / mirror / Atom feed
From: Aaron Conole <aconole@redhat.com>
To: David Marchand <david.marchand@redhat.com>
Cc: dev@dpdk.org,  Michael Santana <maicolgabriel@hotmail.com>,
	 Bruce Richardson <bruce.richardson@intel.com>,
	 Thomas Monjalon <thomas@monjalon.net>
Subject: Re: [PATCH v3 10/18] build: support Undefined Behavior Sanitizer
Date: Fri, 11 Jul 2025 08:19:09 -0400	[thread overview]
Message-ID: <f7tzfdaor7m.fsf@redhat.com> (raw)
In-Reply-To: <20250708122823.3406288-11-david.marchand@redhat.com> (David Marchand's message of "Tue, 8 Jul 2025 14:28:14 +0200")

David Marchand <david.marchand@redhat.com> writes:

> Enable UBSan in GHA.
> There are still a lot of issues so only run unit tests for a "mini"
> target.
>
> Building with debugoptimized forces -O2 and consumes too much memory
> with UBSan, prefer plain build (iow -O0) even though this hides a number
> of build issues.

It's probably okay for many of the issues because we have other builds
in github that should enable the code path analysis.  Maybe someday in
the future we can get this with UBSan as well.

> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---

Acked-by: Aaron Conole <aconole@redhat.com>

> Changes since v2:
> - left the mini configuration alone and instead filtered
>   enabled component when running unit tests with UBSan,
>
> ---
>  .ci/linux-build.sh          | 38 +++++++++++++++++++++++++++++++++++--
>  .github/workflows/build.yml |  5 +++++
>  app/test/suites/meson.build |  3 +--
>  config/meson.build          | 18 +++++++++++++++++-
>  devtools/words-case.txt     |  1 +
>  5 files changed, 60 insertions(+), 5 deletions(-)
>
> diff --git a/.ci/linux-build.sh b/.ci/linux-build.sh
> index e9272d3931..a24820c65b 100755
> --- a/.ci/linux-build.sh
> +++ b/.ci/linux-build.sh
> @@ -44,6 +44,13 @@ catch_coredump() {
>      return 1
>  }
>  
> +catch_ubsan() {
> +    [ "$UBSAN" = "true" ] || return 0
> +    grep -q UndefinedBehaviorSanitizer $2 2>/dev/null || return 0
> +    grep -E "($1|UndefinedBehaviorSanitizer)" $2
> +    return 1
> +}
> +
>  check_traces() {
>      which babeltrace >/dev/null || return 0
>      for file in $(sudo find $HOME -name metadata); do
> @@ -100,7 +107,6 @@ fi
>  
>  OPTS="$OPTS -Dplatform=generic"
>  OPTS="$OPTS -Ddefault_library=$DEF_LIB"
> -OPTS="$OPTS -Dbuildtype=$buildtype"
>  if [ "$STDATOMIC" = "true" ]; then
>  	OPTS="$OPTS -Denable_stdatomic=true"
>  else
> @@ -117,13 +123,39 @@ else
>  fi
>  OPTS="$OPTS -Dlibdir=lib"
>  
> +buildtype=debugoptimized
> +sanitizer=
>  if [ "$ASAN" = "true" ]; then
> -    OPTS="$OPTS -Db_sanitize=address"
> +    sanitizer=${sanitizer:+$sanitizer,}address
> +fi
> +
> +if [ "$UBSAN" = "true" ]; then
> +    sanitizer=${sanitizer:+$sanitizer,}undefined
> +    if [ "$RUN_TESTS" = "true" ]; then
> +        # UBSan takes too much memory with -O2
> +        buildtype=plain
> +        # Only enable test binaries
> +        OPTS="$OPTS -Denable_apps=test,test-pmd"
> +        # Restrict drivers to a minimum set for now
> +        OPTS="$OPTS -Denable_drivers=net/null"
> +        # There are still known issues in various libraries, disable them for now
> +        OPTS="$OPTS -Ddisable_libs=*"
> +        # No examples are run
> +        OPTS="$OPTS -Dexamples="
> +        # The UBSan target takes a good amount of time and headers coverage is done in other
> +        # targets already.
> +        OPTS="$OPTS -Dcheck_includes=false"
> +    fi
> +fi
> +
> +if [ -n "$sanitizer" ]; then
> +    OPTS="$OPTS -Db_sanitize=$sanitizer"
>      if [ "${CC%%clang}" != "$CC" ]; then
>          OPTS="$OPTS -Db_lundef=false"
>      fi
>  fi
>  
> +OPTS="$OPTS -Dbuildtype=$buildtype"
>  OPTS="$OPTS -Dwerror=true"
>  
>  if [ -d build ]; then
> @@ -141,6 +173,7 @@ if [ -z "$cross_file" ]; then
>      configure_coredump
>      devtools/test-null.sh || failed="true"
>      catch_coredump
> +    catch_ubsan DPDK:fast-tests build/meson-logs/testlog.txt
>      check_traces
>      [ "$failed" != "true" ]
>  fi
> @@ -182,6 +215,7 @@ if [ "$RUN_TESTS" = "true" ]; then
>      configure_coredump
>      sudo meson test -C build --suite fast-tests -t 3 || failed="true"
>      catch_coredump
> +    catch_ubsan DPDK:fast-tests build/meson-logs/testlog.txt
>      check_traces
>      [ "$failed" != "true" ]
>  fi
> diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
> index 6c4bc664d0..0c8ca23bbb 100644
> --- a/.github/workflows/build.yml
> +++ b/.github/workflows/build.yml
> @@ -54,6 +54,7 @@ jobs:
>        RISCV64: ${{ matrix.config.cross == 'riscv64' }}
>        RUN_TESTS: ${{ contains(matrix.config.checks, 'tests') }}
>        STDATOMIC: ${{ contains(matrix.config.checks, 'stdatomic') }}
> +      UBSAN: ${{ contains(matrix.config.checks, 'ubsan') }}
>  
>      strategy:
>        fail-fast: false
> @@ -62,6 +63,10 @@ jobs:
>            - os: ubuntu-22.04
>              compiler: gcc
>              mini: mini
> +          - os: ubuntu-22.04
> +            compiler: clang
> +            library: shared
> +            checks: tests+ubsan
>            - os: ubuntu-22.04
>              compiler: gcc
>              checks: stdatomic
> diff --git a/app/test/suites/meson.build b/app/test/suites/meson.build
> index e482373330..0cba63ee12 100644
> --- a/app/test/suites/meson.build
> +++ b/app/test/suites/meson.build
> @@ -72,8 +72,7 @@ foreach suite:test_suites
>              elif not has_hugepage
>                  continue  #skip this tests
>              endif
> -            if not asan and (get_option('b_sanitize') == 'address'
> -                    or get_option('b_sanitize') == 'address,undefined')
> +            if not asan and get_option('b_sanitize').contains('address')
>                  continue  # skip this test
>              endif
>  
> diff --git a/config/meson.build b/config/meson.build
> index f31fef216c..b8a8511a7f 100644
> --- a/config/meson.build
> +++ b/config/meson.build
> @@ -499,7 +499,7 @@ if get_option('b_lto')
>      endif
>  endif
>  
> -if get_option('b_sanitize') == 'address' or get_option('b_sanitize') == 'address,undefined'
> +if get_option('b_sanitize').contains('address')
>      if is_windows
>          error('ASan is not supported on windows')
>      endif
> @@ -519,6 +519,22 @@ if get_option('b_sanitize') == 'address' or get_option('b_sanitize') == 'address
>      endif
>  endif
>  
> +if get_option('b_sanitize').contains('undefined')
> +    if is_windows
> +        error('UBSan is not supported on windows')
> +    endif
> +
> +    if cc.get_id() == 'gcc'
> +        ubsan_dep = cc.find_library('ubsan', required: true)
> +        if (not cc.links('int main(int argc, char *argv[]) { return 0; }',
> +                dependencies: ubsan_dep))
> +            error('broken dependency, "libubsan"')
> +        endif
> +        add_project_link_arguments('-lubsan', language: 'c')
> +        dpdk_extra_ldflags += '-lubsan'
> +    endif
> +endif
> +
>  if get_option('default_library') == 'both'
>      error( '''
>   Unsupported value "both" for "default_library" option.
> diff --git a/devtools/words-case.txt b/devtools/words-case.txt
> index bc35c160ba..d315fde8fe 100644
> --- a/devtools/words-case.txt
> +++ b/devtools/words-case.txt
> @@ -105,6 +105,7 @@ TSO
>  TTL
>  Tx
>  uAPI
> +UBSan
>  UDM
>  UDP
>  ULP


  reply	other threads:[~2025-07-11 12:19 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-19  7:10 [PATCH 00/10] Run with UBSan in GHA David Marchand
2025-06-19  7:10 ` [PATCH 01/10] ci: save ccache on failure David Marchand
2025-06-25 12:16   ` Aaron Conole
2025-06-19  7:10 ` [PATCH 02/10] test/telemetry: fix test calling all commands David Marchand
2025-06-20  9:16   ` Bruce Richardson
2025-06-23  9:54   ` David Marchand
2025-06-19  7:10 ` [PATCH 03/10] test/mempool: fix test without stack driver David Marchand
2025-06-20  8:54   ` Andrew Rybchenko
2025-06-19  7:10 ` [PATCH 04/10] eal: fix plugin dir walk David Marchand
2025-06-20  9:19   ` Bruce Richardson
2025-06-23  9:41     ` David Marchand
2025-06-19  7:10 ` [PATCH 05/10] cmdline: fix port list parsing David Marchand
2025-06-20  9:58   ` Bruce Richardson
2025-06-23  9:40     ` David Marchand
2025-06-23 10:41       ` Bruce Richardson
2025-06-19  7:10 ` [PATCH 06/10] cmdline: fix highest bit " David Marchand
2025-06-20  9:21   ` Bruce Richardson
2025-06-23  9:32     ` David Marchand
2025-06-19  7:10 ` [PATCH 07/10] tailq: fix cast macro for null pointer David Marchand
2025-06-20  9:23   ` Bruce Richardson
2025-06-19  7:10 ` [PATCH 08/10] hash: fix unaligned access in predictable RSS David Marchand
2025-06-19  7:10 ` [PATCH 09/10] stack: fix unaligned accesses on 128-bit David Marchand
2025-06-19  7:10 ` [PATCH 10/10] build: support Undefined Behavior Sanitizer David Marchand
2025-06-25 12:17   ` Aaron Conole
2025-06-23 13:52 ` [PATCH v2 00/10] Run with UBSan in GHA David Marchand
2025-06-23 13:52   ` [PATCH v2 01/10] ci: save ccache on failure David Marchand
2025-06-23 13:52   ` [PATCH v2 02/10] test/telemetry: fix test calling all commands David Marchand
2025-06-24 15:59     ` Marat Khalili
2025-06-26  8:32       ` David Marchand
2025-06-26  9:51         ` Marat Khalili
2025-07-03 14:09           ` David Marchand
2025-07-03 15:08             ` Marat Khalili
2025-06-23 13:52   ` [PATCH v2 03/10] test/mempool: fix test without stack driver David Marchand
2025-06-24 16:21     ` Marat Khalili
2025-06-23 13:52   ` [PATCH v2 04/10] eal: fix plugin dir walk David Marchand
2025-06-25  8:43     ` Marat Khalili
2025-07-03 14:27       ` David Marchand
2025-06-23 13:52   ` [PATCH v2 05/10] cmdline: fix port list parsing David Marchand
2025-06-23 14:00     ` Bruce Richardson
2025-06-26  9:32     ` Marat Khalili
2025-06-23 13:52   ` [PATCH v2 06/10] cmdline: fix highest bit " David Marchand
2025-06-30 15:25     ` Marat Khalili
2025-06-23 13:52   ` [PATCH v2 07/10] tailq: fix cast macro for null pointer David Marchand
2025-06-30 16:06     ` Marat Khalili
2025-06-23 13:52   ` [PATCH v2 08/10] hash: fix unaligned access in predictable RSS David Marchand
2025-06-30 15:32     ` Bruce Richardson
2025-07-01  8:36     ` Konstantin Ananyev
2025-07-08  7:32       ` David Marchand
2025-07-08 17:58         ` Konstantin Ananyev
2025-06-23 13:52   ` [PATCH v2 09/10] stack: fix unaligned accesses on 128-bit David Marchand
2025-06-30 15:33     ` Bruce Richardson
2025-06-23 13:52   ` [PATCH v2 10/10] build: support Undefined Behavior Sanitizer David Marchand
2025-07-08 12:28 ` [PATCH v3 00/18] Run with UBSan in GHA David Marchand
2025-07-08 12:28   ` [PATCH v3 01/18] ci: save ccache on failure David Marchand
2025-07-08 12:28   ` [PATCH v3 02/18] test/telemetry: fix test calling all commands David Marchand
2025-07-08 12:28   ` [PATCH v3 03/18] test/mempool: fix test without stack driver David Marchand
2025-07-08 15:15     ` Morten Brørup
2025-07-08 12:28   ` [PATCH v3 04/18] eal: fix plugin dir walk David Marchand
2025-07-08 12:28   ` [PATCH v3 05/18] cmdline: fix port list parsing David Marchand
2025-07-08 12:28   ` [PATCH v3 06/18] cmdline: fix highest bit " David Marchand
2025-07-08 12:28   ` [PATCH v3 07/18] tailq: fix cast macro for null pointer David Marchand
2025-07-08 12:28   ` [PATCH v3 08/18] hash: fix unaligned access in predictable RSS David Marchand
2025-07-08 12:35     ` Medvedkin, Vladimir
2025-07-08 12:28   ` [PATCH v3 09/18] stack: fix unaligned accesses on 128-bit David Marchand
2025-07-08 15:41     ` Morten Brørup
2025-07-09  8:23     ` Konstantin Ananyev
2025-07-08 12:28   ` [PATCH v3 10/18] build: support Undefined Behavior Sanitizer David Marchand
2025-07-11 12:19     ` Aaron Conole [this message]
2025-07-08 12:28   ` [PATCH v3 11/18] test/telemetry: catch errors in subshell David Marchand
2025-07-08 12:28   ` [PATCH v3 12/18] malloc: fix mp message alignment David Marchand
2025-07-08 12:44     ` Bruce Richardson
2025-07-08 12:46       ` David Marchand
2025-07-08 13:25         ` Bruce Richardson
2025-07-08 13:33           ` David Marchand
2025-07-08 12:28   ` [PATCH v3 13/18] graph: fix stats query with no node xstats David Marchand
2025-07-08 12:28   ` [PATCH v3 14/18] graph: fix unaligned access in stats David Marchand
2025-07-08 12:28   ` [PATCH v3 15/18] eventdev: fix listing timer adapters with telemetry David Marchand
2025-07-08 12:28   ` [PATCH v3 16/18] test/power: fix tests without power drivers David Marchand
2025-07-08 12:47     ` Bruce Richardson
2025-07-08 12:53       ` David Marchand
2025-07-08 13:26         ` Bruce Richardson
2025-07-08 12:28   ` [PATCH v3 17/18] test/raw: fix test without skeleton driver David Marchand
2025-07-08 12:48     ` Bruce Richardson
2025-07-08 12:28   ` [PATCH v3 18/18] ci: extend coverage with UBSan David Marchand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f7tzfdaor7m.fsf@redhat.com \
    --to=aconole@redhat.com \
    --cc=bruce.richardson@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=maicolgabriel@hotmail.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).