public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Tobias Burnus <tobias@codesourcery.com>, Martin Jambor <mjambor@suse.cz>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [patch, libgomp] Fix segfault with plugin-hsa
Date: Wed, 11 Sep 2019 09:49:00 -0000	[thread overview]
Message-ID: <20190911094856.GH2120@tucnak> (raw)
In-Reply-To: <edd363c3-c51e-ef82-7bf3-7413443be7c4@codesourcery.com>

On Wed, Sep 11, 2019 at 11:30:17AM +0200, Tobias Burnus wrote:
> when playing around with offloading, I got an hsa initialization error
> (/dev/... lacked write permission) and the library call returned with an
> error status – but hsa_fns.hsa_status_string_fn didn't set the message to
> the string variable.
> 
> Hence, the string variable was uninitialized and libgomp crashed when
> printing the error message; "[unknown]" is not the best HSA run-time
> message, but at least the primary message is shown and there is no crash :-)

LGTM, but give Martin (CCed) as the author a chance to chime in.

> 2019-09-11  Tobias Burnus  <tobias@codesourcery.com>
> 
>         * plugin/plugin-hsa.c (hsa_warn, hsa_fatal, hsa_error): Ensure
>         string is initialized.
> 
> diff --git a/libgomp/plugin/plugin-hsa.c b/libgomp/plugin/plugin-hsa.c
> index 80f23f9beb6..c0837d04e5d 100644
> --- a/libgomp/plugin/plugin-hsa.c
> +++ b/libgomp/plugin/plugin-hsa.c
> @@ -289,7 +289,7 @@ hsa_warn (const char *str, hsa_status_t status)
>    if (!debug)
>      return;
> -  const char *hsa_error_msg;
> +  const char *hsa_error_msg = "[unknown]";
>    hsa_fns.hsa_status_string_fn (status, &hsa_error_msg);
>    fprintf (stderr, "HSA warning: %s\nRuntime message: %s", str, hsa_error_msg);
> @@ -301,7 +301,7 @@ hsa_warn (const char *str, hsa_status_t status)
>  static void
>  hsa_fatal (const char *str, hsa_status_t status)
>  {
> -  const char *hsa_error_msg;
> +  const char *hsa_error_msg = "[unknown]";
>    hsa_fns.hsa_status_string_fn (status, &hsa_error_msg);
>    GOMP_PLUGIN_fatal ("HSA fatal error: %s\nRuntime message: %s", str,
>  		     hsa_error_msg);
> @@ -313,7 +313,7 @@ hsa_fatal (const char *str, hsa_status_t status)
>  static bool
>  hsa_error (const char *str, hsa_status_t status)
>  {
> -  const char *hsa_error_msg;
> +  const char *hsa_error_msg = "[unknown]";
>    hsa_fns.hsa_status_string_fn (status, &hsa_error_msg);
>    GOMP_PLUGIN_error ("HSA fatal error: %s\nRuntime message: %s", str,
>  		     hsa_error_msg);
> 

	Jakub

  reply	other threads:[~2019-09-11  9:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-11  9:30 Tobias Burnus
2019-09-11  9:49 ` Jakub Jelinek [this message]
2019-09-11 12:07   ` Martin Jambor

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=20190911094856.GH2120@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mjambor@suse.cz \
    --cc=tobias@codesourcery.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 read-only IMAP folder(s) and NNTP newsgroup(s).