From patchwork Mon Mar 20 10:26:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 125312 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9E326427E0; Mon, 20 Mar 2023 11:26:40 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 838B440A7F; Mon, 20 Mar 2023 11:26:40 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 8074D406BC for ; Mon, 20 Mar 2023 11:26:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679307998; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=W9QNH0H2eQGuMNHClXtT+wSmUnuFmkxT0WOjR92OzmM=; b=L5p0skZeyr3ZhT7L803yp9+jokG0MWoPRJwvYiEgRKHWyFewzfqBBy6WvbHzLpEy0kswcm BFbBXaA9f16Rq6QqauEMKei6PgpgxLP21aJLCMYHsCCzOQW8iFySbxfyMaa+Sk3K8V/Spj /FWXfgdFJuoV92qbgloT2TZKbNJfxX4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-606-2ephxe8ZMFqAIRaqrFtH0g-1; Mon, 20 Mar 2023 06:26:34 -0400 X-MC-Unique: 2ephxe8ZMFqAIRaqrFtH0g-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7F9D2101A54F; Mon, 20 Mar 2023 10:26:34 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id C16D82027047; Mon, 20 Mar 2023 10:26:33 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Srikanth Yalavarthi , Anup Prabhu Subject: [PATCH 1/2] app/mldev: fix build with debug Date: Mon, 20 Mar 2023 11:26:22 +0100 Message-Id: <20230320102624.1258816-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Compiling with -O0 and -g triggers these warnings: ../app/test-mldev/test_inference_common.c: In function ‘ml_request_finish’: ../app/test-mldev/test_inference_common.c:946:51: error: ‘.q.’ directive output may be truncated writing 3 bytes into a region of size between 0 and 4095 [-Werror=format-truncation=] 946 | snprintf(str, sizeof(str) - 1, "%s.q.%d", | ^~~ t->cmn.opt->filelist[req->fid].output, obj_idx); ../app/test-mldev/test_inference_common.c:946:48: note: using the range [-2147483648, 2147483647] for directive argument 946 | snprintf(str, sizeof(str) - 1, "%s.q.%d", | ^~~~~~~~~ t->cmn.opt->filelist[req->fid].output, obj_idx); ../app/test-mldev/test_inference_common.c:946:17: note: ‘snprintf’ output between 5 and 4110 bytes into a destination of size 4095 946 | snprintf(str, sizeof(str) - 1, "%s.q.%d", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t->cmn.opt->filelist[req->fid].output, obj_idx); ../app/test-mldev/test_inference_common.c:952:51: error: ‘.’ directive output may be truncated writing 1 byte into a region of size between 0 and 4095 [-Werror=format-truncation=] 952 | snprintf(str, sizeof(str) - 1, "%s.%d", | ^ t->cmn.opt->filelist[req->fid].output, obj_idx); ../app/test-mldev/test_inference_common.c:952:48: note: using the range [-2147483648, 2147483647] for directive argument 952 | snprintf(str, sizeof(str) - 1, "%s.%d", | ^~~~~~~ t->cmn.opt->filelist[req->fid].output, obj_idx); ../app/test-mldev/test_inference_common.c:952:17: note: ‘snprintf’ output between 3 and 4108 bytes into a destination of size 4095 952 | snprintf(str, sizeof(str) - 1, "%s.%d", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t->cmn.opt->filelist[req->fid].output, obj_idx); ../app/test-mldev/test_inference_common.c:929:51: error: ‘.q’ directive output may be truncated writing 2 bytes into a region of size between 0 and 4095 [-Werror=format-truncation=] 929 | snprintf(str, sizeof(str) - 1, "%s.q", | ^~ t->cmn.opt->filelist[req->fid].output); ../app/test-mldev/test_inference_common.c:929:17: note: ‘snprintf’ output between 3 and 4098 bytes into a destination of size 4095 929 | snprintf(str, sizeof(str) - 1, "%s.q", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t->cmn.opt->filelist[req->fid].output); ../app/test-mldev/test_inference_common.c:935:51: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=] 935 | snprintf(str, sizeof(str) - 1, "%s", | ^ t->cmn.opt->filelist[req->fid].output); ../app/test-mldev/test_inference_common.c:935:17: note: ‘snprintf’ output between 1 and 4096 bytes into a destination of size 4095 935 | snprintf(str, sizeof(str) - 1, "%s", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t->cmn.opt->filelist[req->fid].output); Fix unsigned integer format, and switch to dynamic allocations. Fixes: da6793390596 ("app/mldev: support inference validation") Signed-off-by: David Marchand Acked-by: Srikanth Yalavarthi --- app/test-mldev/test_inference_common.c | 29 ++++++++++++++++++-------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/app/test-mldev/test_inference_common.c b/app/test-mldev/test_inference_common.c index e85f32be60..f7ce732d9a 100644 --- a/app/test-mldev/test_inference_common.c +++ b/app/test-mldev/test_inference_common.c @@ -3,6 +3,7 @@ */ #include +#include #include #include @@ -901,8 +902,8 @@ ml_request_finish(struct rte_mempool *mp, void *opaque, void *obj, unsigned int struct test_inference *t = ml_test_priv((struct ml_test *)opaque); struct ml_request *req = (struct ml_request *)obj; struct ml_model *model = &t->model[req->fid]; - char str[PATH_MAX]; bool error = false; + char *dump_path; RTE_SET_USED(mp); @@ -926,14 +927,18 @@ ml_request_finish(struct rte_mempool *mp, void *opaque, void *obj, unsigned int dump_output_pass: if (obj_idx == 0) { /* write quantized output */ - snprintf(str, PATH_MAX, "%s.q", t->cmn.opt->filelist[req->fid].output); - ML_OPEN_WRITE_GET_ERR(str, req->output, model->out_qsize, error); + if (asprintf(&dump_path, "%s.q", t->cmn.opt->filelist[req->fid].output) == -1) + return; + ML_OPEN_WRITE_GET_ERR(dump_path, req->output, model->out_qsize, error); + free(dump_path); if (error) return; /* write dequantized output */ - snprintf(str, PATH_MAX, "%s", t->cmn.opt->filelist[req->fid].output); - ML_OPEN_WRITE_GET_ERR(str, model->output, model->out_dsize, error); + if (asprintf(&dump_path, "%s", t->cmn.opt->filelist[req->fid].output) == -1) + return; + ML_OPEN_WRITE_GET_ERR(dump_path, model->output, model->out_dsize, error); + free(dump_path); if (error) return; } @@ -943,14 +948,20 @@ ml_request_finish(struct rte_mempool *mp, void *opaque, void *obj, unsigned int dump_output_fail: if (t->cmn.opt->debug) { /* dump quantized output buffer */ - snprintf(str, PATH_MAX, "%s.q.%d", t->cmn.opt->filelist[req->fid].output, obj_idx); - ML_OPEN_WRITE_GET_ERR(str, req->output, model->out_qsize, error); + if (asprintf(&dump_path, "%s.q.%d", t->cmn.opt->filelist[req->fid].output, + obj_idx) == -1) + return; + ML_OPEN_WRITE_GET_ERR(dump_path, req->output, model->out_qsize, error); + free(dump_path); if (error) return; /* dump dequantized output buffer */ - snprintf(str, PATH_MAX, "%s.%d", t->cmn.opt->filelist[req->fid].output, obj_idx); - ML_OPEN_WRITE_GET_ERR(str, model->output, model->out_dsize, error); + if (asprintf(&dump_path, "%s.%d", t->cmn.opt->filelist[req->fid].output, + obj_idx) == -1) + return; + ML_OPEN_WRITE_GET_ERR(dump_path, model->output, model->out_dsize, error); + free(dump_path); if (error) return; } From patchwork Mon Mar 20 10:26:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 125313 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C65FA427E0; Mon, 20 Mar 2023 11:26:44 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B8A95410F3; Mon, 20 Mar 2023 11:26:44 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 1E185406BC for ; Mon, 20 Mar 2023 11:26:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679308003; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WxOs+ge8n2z1PpFhzksDtNZjWpeoofb1VfW6N/vlKLw=; b=IZ8Pa8k/ulyLsmpRpjkXBWDdZBUjwOYHgJxiZjJcjtQwAdtFt+ByH98wkn2yaRiepc3v+L sLTDJYxFtEDSpBi6Fkw5gSY7C0ZJ+n0PyTwOyCnJuD3DeQI8yAcgq1A0cLCVOkJL/PcIix ZIQmvovjZ9+d2PT7U11EHoQJqIZNhd0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-131-516XRPUkNcaTtiwKC0gfFA-1; Mon, 20 Mar 2023 06:26:37 -0400 X-MC-Unique: 516XRPUkNcaTtiwKC0gfFA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 43A7588B7A1; Mon, 20 Mar 2023 10:26:37 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id 89C064619F4; Mon, 20 Mar 2023 10:26:36 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Aaron Conole , Michael Santana Subject: [PATCH 2/2] ci: test compilation with debug Date: Mon, 20 Mar 2023 11:26:23 +0100 Message-Id: <20230320102624.1258816-2-david.marchand@redhat.com> In-Reply-To: <20230320102624.1258816-1-david.marchand@redhat.com> References: <20230320102624.1258816-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org We often miss compilation issues with -O0 -g. Add a test in GHA. Signed-off-by: David Marchand --- .ci/linux-build.sh | 8 +++++++- .github/workflows/build.yml | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.ci/linux-build.sh b/.ci/linux-build.sh index ab0994388a..150b38bd7a 100755 --- a/.ci/linux-build.sh +++ b/.ci/linux-build.sh @@ -65,6 +65,12 @@ if [ "$RISCV64" = "true" ]; then cross_file=config/riscv/riscv64_linux_gcc fi +buildtype=debugoptimized + +if [ "$BUILD_DEBUG" = "true" ]; then + buildtype=debug +fi + if [ "$BUILD_DOCS" = "true" ]; then OPTS="$OPTS -Denable_docs=true" fi @@ -85,7 +91,7 @@ fi OPTS="$OPTS -Dplatform=generic" OPTS="$OPTS -Ddefault_library=$DEF_LIB" -OPTS="$OPTS -Dbuildtype=debugoptimized" +OPTS="$OPTS -Dbuildtype=$buildtype" OPTS="$OPTS -Dcheck_includes=true" if [ "$MINI" = "true" ]; then OPTS="$OPTS -Denable_drivers=net/null" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 154be70cc1..d90ecfc6f0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,6 +18,7 @@ jobs: ABI_CHECKS: ${{ contains(matrix.config.checks, 'abi') }} ASAN: ${{ contains(matrix.config.checks, 'asan') }} BUILD_32BIT: ${{ matrix.config.cross == 'i386' }} + BUILD_DEBUG: ${{ contains(matrix.config.checks, 'debug') }} BUILD_DOCS: ${{ contains(matrix.config.checks, 'doc') }} CC: ccache ${{ matrix.config.compiler }} DEF_LIB: ${{ matrix.config.library }} @@ -37,6 +38,9 @@ jobs: - os: ubuntu-20.04 compiler: gcc mini: mini + - os: ubuntu-20.04 + compiler: gcc + checks: debug - os: ubuntu-20.04 compiler: gcc checks: abi+doc+tests