From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 38E1445B61; Fri, 18 Oct 2024 00:59:01 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E0E254065A; Fri, 18 Oct 2024 00:58:58 +0200 (CEST) Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by mails.dpdk.org (Postfix) with ESMTP id 118264021E for ; Fri, 18 Oct 2024 00:58:56 +0200 (CEST) Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-207115e3056so11862525ad.2 for ; Thu, 17 Oct 2024 15:58:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1729205935; x=1729810735; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XFF9RZjLfecFFTrjNC2IbrHIwfx4+zkdsFuxZVRPEac=; b=l82UA5EgVFyt056Wo8S9dU/o2nSjZkGlchGa5wKahBS2RCdrUWMcbnWwDPBpyKgTEq GwL3fSJZHeDCwIo0GOZct1exzprngE/59vf5CN294y+D5SiaQ31jK802QEvDVZhIMsk6 qeArDTzAfEHxwsnDrQnn7qZxNCOdWq44HXfmcnu+GikqHpLIARzIIZuiRL44pOU4wQ/m rfVU5AgNzzsXdyZKhXVgvohkYz5xQtWedgSCibRSDt+k1YKe2eKVVkHVtZWVPhKshaqD /i3pz00QKUESmKXzkSjrYFB6ktdHBYi2FAc4jTjTJYD9u0xRs/u1lmPd06xgLRSYTOuY QS0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729205935; x=1729810735; 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=XFF9RZjLfecFFTrjNC2IbrHIwfx4+zkdsFuxZVRPEac=; b=J1G49Q4S2kXpyxKsTUhi+DqJtAn4Xuo7QudGKlGmR7jqWY9GMT98kTrgyqQC0Gzz1O 3+6iRPqJ6QLBYCA4VaF0lEADpmpG4zu8vkiHH2RAAmYdE9fECh+Q/xN0UrfzsPBlv3V6 zbDkB5daoWLwrih4DplKLOuqIKyEoWouEukrv6xJP5N1w7xnUUr5wcOVYE27ky7DHLYN ZgCK5xzBvM0W+MeZ3+bsg5v/LNVcafcpJQYS9Ik0HNvwMKo2WSnSMEazbr6Pj9JY7CQW RmnBUSfmi6tTKwzETE+4tZ2zIv7bQ3Y1nBdCSWPA1PWNlWPtuozs5MIa8UrlL8VzAwCF MdPQ== X-Gm-Message-State: AOJu0YzPIFuZrd3YGXsiMsY/fQnx2RCQpXVVxw//JR2KVEHo1tyKbtLW s261E46a6TXMqELb0MlX8AVLQDoXeDhBJNGLSGys38YZKepK7HBUUXy1PSBAZb6rKKdonmNw9qf 9 X-Google-Smtp-Source: AGHT+IFYzplrV/zs9juPFb6wjdViWo0OFfuCYO/wBMbkIQsfYOwn8jf3rBIVQ16fmwjGmjJnIyXeqw== X-Received: by 2002:a17:902:e544:b0:20c:f39e:4c15 with SMTP id d9443c01a7336-20e5a7750c8mr6822015ad.22.1729205935203; Thu, 17 Oct 2024 15:58:55 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20e5a71ee35sm1544685ad.17.2024.10.17.15.58.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 15:58:54 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Elena Agostini Subject: [PATCH 1/2] test-gpudev: avoid use-after-free and free-non-heap warnings Date: Thu, 17 Oct 2024 15:58:03 -0700 Message-ID: <20241017225844.235401-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241017225844.235401-1-stephen@networkplumber.org> References: <20241017225844.235401-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 This test intentionally frees a bad pointer in GPU memory, and GCC sees that at compile time. Suppress the warnings to allow the test to run. Signed-off-by: Stephen Hemminger --- app/test-gpudev/main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/test-gpudev/main.c b/app/test-gpudev/main.c index f065e6cd81..14df14d528 100644 --- a/app/test-gpudev/main.c +++ b/app/test-gpudev/main.c @@ -96,6 +96,13 @@ alloc_gpu_memory(uint16_t gpu_id) goto error; } + /* GCC 11 or later, is able to detect use-after-free and calling free on no-pointer + * at compilation, but want to allow these tests to still work. + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wuse-after-free" +#pragma GCC diagnostic ignored "-Wfree-nonheap-object" + ret = rte_gpu_mem_free(gpu_id, (uint8_t *)(ptr_1)+0x700); if (ret < 0) { printf("GPU memory 0x%p NOT freed: GPU driver didn't find this memory address internally.\n", @@ -128,6 +135,7 @@ alloc_gpu_memory(uint16_t gpu_id) rte_gpu_mem_free(gpu_id, ptr_1); rte_gpu_mem_free(gpu_id, ptr_2); +#pragma GCC diagnostic pop printf("\n=======> TEST: FAILED\n"); return -1; } @@ -228,12 +236,12 @@ gpu_mem_cpu_map(uint16_t gpu_id) } printf("GPU memory CPU unmapped, 0x%p not valid anymore\n", ptr_cpu); + printf("GPU memory 0x%p freeing\n", ptr_gpu); ret = rte_gpu_mem_free(gpu_id, ptr_gpu); if (ret < 0) { fprintf(stderr, "rte_gpu_mem_free returned error %d\n", ret); goto error; } - printf("GPU memory 0x%p freed\n", ptr_gpu); printf("\n=======> TEST: PASSED\n"); return 0; -- 2.45.2