Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10643664ybi; Thu, 25 Jul 2019 02:58:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqw71ODzlZFz9kXQ7d+mW0+B+RGJiJdgrVoAX+ldQXnCXr6b3fzn+Yp1ZNR7KzHVBGR+6g9/ X-Received: by 2002:a62:ac1a:: with SMTP id v26mr16104197pfe.184.1564048733497; Thu, 25 Jul 2019 02:58:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564048733; cv=none; d=google.com; s=arc-20160816; b=qHzRdot7dXqu9Z7VpW61HfQaLejCsk2P/yQnxQ5QNTY97aHBr6CjjZ72VGpwddP0Ti B4y34DjowhRHF4dA7VN2V6OLg1c0vFjW4VUOs7TsK2KR5yHJ0HYOyrhr7fj96ob9vNqV 5shzGsgJQXw8nsdKhRyDzoshR5igvUZdUIPf1LogXhE0h9mSuwtiQ5BSrpv0DBTN9+Sm vLY8XLIA5raQ3lCM+t1W5XKfBOM5UR7gYQpvQhWijO+HlPWXmypB4MC9eMLgyGjTJisL +biu3q8BJWf58p2hvdpDOIK8jZXZjiqamZRDEemmMR9vcingkW/vCtQnXKN60FELFXuA nh9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=VQaWcfe07h7xkPV4srIxPAegZrqwtOuxXwp48xMCRFw=; b=c6o2x3KiGAq3kND17lXnBki+VuMgt+FOcr1uSmJ7+udt+68i4b0owX8dkjxHRdHk9H zMt8L1KswVbF4G5TQu3+ZeBMW7+4vyuwLpxNPiJj/FMoFg5zfeb4t094OPq17VQDHTtC yCQhEWtxxYdZgIqrpOF2hwueg7LemNUYeO1F6W8XAFvL0DXwOirmw4KIgBs7I/hfXhg0 uSZV5wkN9em4dIoHjskQtkReAZq6a0gOQYOJ0jXoJApxZ345AKDzC6taxIM/iiQrTQs0 uCkg9oqQmiG1dbB0BBAj8zcMwkDqfbEnb4BZcXJ/vuzPMESKXxegb+lonkVB5sGExp96 3+KA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=JVgAaFcP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g13si19556825pgr.297.2019.07.25.02.58.34; Thu, 25 Jul 2019 02:58:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=JVgAaFcP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388120AbfGXXpQ (ORCPT + 99 others); Wed, 24 Jul 2019 19:45:16 -0400 Received: from mail-qk1-f202.google.com ([209.85.222.202]:42520 "EHLO mail-qk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387978AbfGXXpN (ORCPT ); Wed, 24 Jul 2019 19:45:13 -0400 Received: by mail-qk1-f202.google.com with SMTP id 199so40874958qkj.9 for ; Wed, 24 Jul 2019 16:45:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=VQaWcfe07h7xkPV4srIxPAegZrqwtOuxXwp48xMCRFw=; b=JVgAaFcP4BXC+4Nk6aWkGbBNbormFNb7B2J2uLoqHwsOLu0+A9xD2RsQs7Jj7XcDz0 GWagGjRxlDZK3/Ovx7o5c7c8ffOh8AdWIj6eumKSiSYIy4AXuQDI2YB3HJ6SsJ6Esxgq sGam93Bf/ar1WP2KpXBe4WS8c0gusArStRpbSLDQ3xanZdaFy0k+VBUfhl/nir8kPlDs LB0sWJyIZ3Fh9hqJOkO6/7YzmpjvR52IOA6CzztS5Bl+zY1BcUT+pzJUYJnkWIlanmcl O0C3Xkh6Ema6NvFIGt8IVZuLkrLZ4sO3r3WprP4U6/0qKEQ4qRNRTUd7Q1seDttF8BBI cbOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=VQaWcfe07h7xkPV4srIxPAegZrqwtOuxXwp48xMCRFw=; b=iYrDXYiVNn1NhywQk1DrMm65PoLcNu9ogkU2q1cbmeqTuBO/E0HdGO99DkU+AX4/yJ I3aHQVcRS6MlbDuxrhJuskxGetMFEMHN9QCo+siEs9EcBGl0U4deQzFNaRxXg4Ev5S/N ChzkAl/Wjz6lgd06BYuRhKQ2u0bXYkv65YeRyhfyfBSNN+maleGOOVcrZPNGn5DAKJT5 VaB82OWpo72RlRH5CdTWsHHk8zGd+eXZX+1kB4GTHEOOazd6crUiXImVlt9TXUB38Mz+ 3T2tOqTgVZ0DFUguIjm5BLL4b2hlQciiWKLxhfgdQO5wyzMrkd8GJkQTroE71zW8NLny Mi3g== X-Gm-Message-State: APjAAAXGXLc3bAo0wMzBeA5yDUHqTdy2tOAEdr/iazhgl5THTOtdP5se YKhCrdxfRW5GIU4KUZlRjnnwYEgP X-Received: by 2002:a37:b0c6:: with SMTP id z189mr56205530qke.208.1564011911372; Wed, 24 Jul 2019 16:45:11 -0700 (PDT) Date: Wed, 24 Jul 2019 16:45:00 -0700 In-Reply-To: <20190724234500.253358-1-nums@google.com> Message-Id: <20190724234500.253358-4-nums@google.com> Mime-Version: 1.0 References: <20190724234500.253358-1-nums@google.com> X-Mailer: git-send-email 2.22.0.657.g960e92d24f-goog Subject: [PATCH 3/3] Fix sched-messaging.c use of uninitialized value errors From: Numfor Mbiziwo-Tiapo To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, songliubraving@fb.com, mbd@fb.com Cc: linux-kernel@vger.kernel.org, irogers@google.com, eranian@google.com, Numfor Mbiziwo-Tiapo Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Our local MSAN (Memory Sanitizer) build of perf throws use of uninitialized value warnings in "tools/perf/bench/sched-messaging.c" when running perf bench. The first warning comes from the "ready" function where the "dummy" char is declared and then passed into "write" without being initialized. Initializing "dummy" to any character silences the warning. The second warning comes from the "sender" function where a "write" call is made to write the contents from the "data" char array when it has not yet been initialized. Calling memset on "data" silences the warning. To reproduce this warning, build perf by running: make -C tools/perf CLANG=1 CC=clang EXTRA_CFLAGS="-fsanitize=memory\ -fsanitize-memory-track-origins" (Additionally, llvm might have to be installed and clang might have to be specified as the compiler - export CC=/usr/bin/clang) then running: tools/perf/perf bench sched all Please see the cover letter for why false positive warnings may be generated. Signed-off-by: Numfor Mbiziwo-Tiapo --- tools/perf/bench/sched-messaging.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/perf/bench/sched-messaging.c b/tools/perf/bench/sched-messaging.c index f9d7641ae833..d22d7b7b591d 100644 --- a/tools/perf/bench/sched-messaging.c +++ b/tools/perf/bench/sched-messaging.c @@ -69,7 +69,7 @@ static void fdpair(int fds[2]) /* Block until we're ready to go */ static void ready(int ready_out, int wakefd) { - char dummy; + char dummy = 'N'; struct pollfd pollfd = { .fd = wakefd, .events = POLLIN }; /* Tell them we're ready. */ @@ -87,6 +87,7 @@ static void *sender(struct sender_context *ctx) char data[DATASIZE]; unsigned int i, j; + memset(data, 'N', DATASIZE); ready(ctx->ready_out, ctx->wakefd); /* Now pump to every receiver. */ -- 2.22.0.657.g960e92d24f-goog