linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luis Henriques <lhenriques@suse.de>
To: Peter Oberparleiter <oberpar@linux.ibm.com>
Cc: linux-kernel@vger.kernel.org, "Martin Liška" <mliska@suse.cz>,
	"Michael Matz" <matz@suse.de>
Subject: Re: gcov: NULL pointer dereference with gcc 9.3.1
Date: Tue, 8 Jun 2021 13:46:22 +0100	[thread overview]
Message-ID: <YL9mngUhaBjTawDD@suse.de> (raw)
In-Reply-To: <e8207b09-265b-60a6-7fb0-51dda7cf59d6@linux.ibm.com>

On Mon, Jun 07, 2021 at 04:32:14PM +0200, Peter Oberparleiter wrote:
> On 02.06.2021 16:22, Luis Henriques wrote:
> > On Wed, Jun 02, 2021 at 02:35:31PM +0200, Peter Oberparleiter wrote:
> >> On 01.06.2021 17:56, Luis Henriques wrote:
> >>> Hi!
> >>>
> >>> Maybe this is a known (gcc?) issue, but I'm seeing a NULL pointer splat if
> >>> I instrument my kernel (or a module, more specifically) using gcc 9.3.1.
> >>>
> >>> It looks like, during initialization in __gcov_init(), gcov_info struct is
> >>> invalid: the filename seems to be correct but ->function is NULL and
> >>> ->n_functions contains garbage.
> >>
> >> Thanks for reporting this issue. The symptoms you're seeing look similar
> >> to those that occur when the struct gcov_info layout emitted by GCC does
> >> not match the one used by the kernel. In particular a change in the
> >> GCOV_COUNTER value can cause this behavior.
> >>
> >> I've checked upstream GCC 9.3.1 and it seems to match what is used by
> >> the kernel for that GCC version. Could you provide the exact version of
> >> the compiler you are using? Both 'gcc --version' output and the GCC
> >> package version should help. Also what architecture are you seeing this on?
> > 
> > Here's the output of 'gcc --version':
> > 
> > gcc (SUSE Linux) 9.3.1 20200903 [revision 9790fa53b48f3a48e0f7a7ad65e2bbf3b206a7b0]
> > Copyright (C) 2019 Free Software Foundation, Inc.
> > This is free software; see the source for copying conditions.  There is NO
> > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> > 
> > This is the version shipped with openSUSE Tumbleweed, and I'm using it to
> > compile an x86_64 kernel.  Regarding the 'package version', I'm assuming
> > the packages as per the distro package version, right?  Here's the data
> > from 'zypper info':
> > 
> > Information for package gcc9:
> > -----------------------------
> > Repository     : Main Repository (OSS)
> > Name           : gcc9
> > Version        : 9.3.1+git1684-3.5
> > Arch           : x86_64
> > Vendor         : openSUSE
> > Installed Size : 94.6 MiB
> > Installed      : Yes (automatically)
> > Status         : up-to-date
> > Source package : gcc9-9.3.1+git1684-3.5.src
> 
> I've checked the source you referenced and found that it contains a
> backport of a change to gcov_info that was only introduced with GCC 10
> to upstream source: the value of GCOV_COUNTERS was reduced from 9 to 8.
> 
> Since I don't think it's feasible to implement support for such
> vendor-specific changes in the upstream kernel source my suggestion for
> you would be to either
> 
> a) fall back to a vanilla GCC version,
> b) fall back to a known-to-work vendor-specific GCC version (GCC 10
>    should be fine), or
> c) to manually change the GCOV_COUNTERS value in
>    linux/kernel/gcov/gcc_4_7.c to 8.

Thanks a lot for looking Peter, I've already reported this issue to the
maintainers.  Hopefully it'll soon be looked at.  Anyway, to be honest I
just hit this issue accidentally -- I don't really have a requirement on
using this version specifically.

Cheers,
--
Luís

> > Do you have a link with binaries I could test for upstream 9.3.1?  I
> > checked [1] but there's only 9.3.0.
> 
> I'm not sure there is any. My analysis was based on source code for
> 9.3.0 alone.
> 
> 
> Regards,
>   Peter Oberparleiter
> 
> -- 
> Peter Oberparleiter
> Linux on Z Development - IBM Germany

      reply	other threads:[~2021-06-08 12:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-01 15:56 gcov: NULL pointer dereference with gcc 9.3.1 Luis Henriques
2021-06-02 10:24 ` [RFC PATCH] gcov: add basic gcov_info validation to gcov initialization Luis Henriques
2021-06-07  9:59   ` Peter Oberparleiter
2021-06-07 10:48     ` Luis Henriques
2021-06-02 12:35 ` gcov: NULL pointer dereference with gcc 9.3.1 Peter Oberparleiter
2021-06-02 14:22   ` Luis Henriques
2021-06-07 14:32     ` Peter Oberparleiter
2021-06-08 12:46       ` Luis Henriques [this message]

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=YL9mngUhaBjTawDD@suse.de \
    --to=lhenriques@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matz@suse.de \
    --cc=mliska@suse.cz \
    --cc=oberpar@linux.ibm.com \
    /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).