Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3493472pxj; Tue, 1 Jun 2021 06:38:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0J2fyHvKMIOV+cMinxa0JxKyoPlUKhLNP671nOGNt9ggEjiInli5FEow/b+/gA6yJEaUE X-Received: by 2002:a6b:fb0f:: with SMTP id h15mr21137758iog.24.1622554721011; Tue, 01 Jun 2021 06:38:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622554721; cv=none; d=google.com; s=arc-20160816; b=Jv5y1dzyHb8HgrfRVN0yayotDTBEgPvikiHNnwufp4RMffSwoyEX5Rj9So+NrFBeTO wtzLTH155h3B/J72z/W+dGaYhaVQQuYp1pfbveZcvoB9vRtl6bmN2RiXXVQE+ZyGa5fE 85VfZEWxHPXrPGeM4yLAMuMi+G8k1kCpYhr+zGwVIy1OASeTgZbYeqRepfL7AzlnfBlN iyxolUWt4Ja+61clRW01KWvmiNr359ES7i89s5AfHU7SCRZBLJckm04r4WX3CLYnl+IC JLPUciD/eD3DXwEprzMbdjVAbPsUG/JIbJXeQ76Yp6puobrr2oFvbVss36qDJ5UHvR9F u1TQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=TxL1K15pHkcUVirlMnwAPIxYdAHBIsFRQ3q1NBv+2r0=; b=cacddTuAphIVwqnIafVWvbzcf84XKsBvZqi/0xMiP1JKB57/AjOgKNUq3uJQnUNPqv BbG7mPxeQKpkYmV0UyQ7xNo1MiRstGSViRRZtQ7Rljhngu4TG1FBnYQrnerHiVP45zlj /J0A+k0RPcfXwvmGuNfQOokmOom7TNov3xYzZkS4zOZLcWAXafsfvcyXTOG7OI7GBWzQ I8+/Ox54qqybGe38G8bpzqLrjD8o1Ubc6P079OQPs7wRVeAI+JovQAe+h86pixrmVYTz so099FAEexAm2ajxJfXAzqmhFN8xsvG3lh1xiO4xLZ0ZPqjhWPyF92xo+pwxOrzz2WqZ OHvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VH4nF+u0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d20si19246091jak.40.2021.06.01.06.38.27; Tue, 01 Jun 2021 06:38:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VH4nF+u0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233949AbhFANj0 (ORCPT + 99 others); Tue, 1 Jun 2021 09:39:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:55684 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233584AbhFANj0 (ORCPT ); Tue, 1 Jun 2021 09:39:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 636CC61263; Tue, 1 Jun 2021 13:37:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622554664; bh=pkFlErKqCbMKfuoBC4+Cn0CMLj9ZRkztvcHyPpIn5L0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=VH4nF+u0ltS3vwi4R55bofpmRvLFeHe3SG8sVb2sAEArEdSxUI4ZjA5R7Iml+j7uw L0gYNIV0OM9dO2g9YGEMvYX58cQ5sgaJLXBdmSdR5B7rTW/7fIcXwnDXigzJJOHNSK O9O464pO67RZADXp09JWscqiZx6LxIQTqfF8jXENL5FCG3aqzQ4jzYrp0jfPxxyG/a 8MVC5pA+ByenUlfLOc6RM+uxyANO04YLGQz5BYZBhxGfMcde8WaxlgB96rUSnD9eXj HkY5aOQWRdvDmoQ1RThoXQUyOM6HsGk1kiX7Bf9fS9fb4gNQaYXWguHv9vFLCmK6Ix guEORrEK68Llg== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id A5EAB4011C; Tue, 1 Jun 2021 10:37:41 -0300 (-03) Date: Tue, 1 Jun 2021 10:37:41 -0300 From: Arnaldo Carvalho de Melo To: Riccardo Mancini Cc: Namhyung Kim , Ian Rogers , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] perf: fix segfault when wrong option for --debug is provided Message-ID: References: <20210531212828.240077-1-rickyman7@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210531212828.240077-1-rickyman7@gmail.com> X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Mon, May 31, 2021 at 11:28:28PM +0200, Riccardo Mancini escreveu: > The command `perf --debug record` causes a segfault instead of notifying > the user of the unrecognized option for --debug (the correct syntax would > be `perf --debug verbose=2 record`). > > The bug is caused by a call to pr_err before debug_file (debug.c:34) is > set via perf_debug_setup(). It has been introduced in > commit 8abceacff87d ("perf debug: Add debug_set_file function"). > > This patch resolves the bug by calling perf_debug_setup earlier in the > main, so that debug_file is set to stderr before any call to a debug > printing function is made. Ian fixed this earlier and it is already even upstream: https://git.kernel.org/torvalds/c/c59870e2110e1229a6e4 Thanks, - Arnaldo > Signed-off-by: Riccardo Mancini > --- > tools/perf/perf.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/tools/perf/perf.c b/tools/perf/perf.c > index 20cb91ef06ffc..cffbab2d085a7 100644 > --- a/tools/perf/perf.c > +++ b/tools/perf/perf.c > @@ -448,6 +448,7 @@ int main(int argc, const char **argv) > pager_init(PERF_PAGER_ENVIRONMENT); > > libperf_init(libperf_print); > + perf_debug_setup(); > > cmd = extract_argv0_path(argv[0]); > if (!cmd) > @@ -531,8 +532,6 @@ int main(int argc, const char **argv) > */ > pthread__block_sigwinch(); > > - perf_debug_setup(); > - > while (1) { > static int done_help; > > -- > 2.23.0 > -- - Arnaldo