Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Aleksandar Ristovski <aristovski@qnx.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: dangling pointer in so_list
Date: Fri, 02 Sep 2011 20:45:00 -0000	[thread overview]
Message-ID: <20110902201715.GA16280@host1.jankratochvil.net> (raw)
In-Reply-To: <j3qkcq$mou$1@dough.gmane.org>

On Fri, 02 Sep 2011 15:06:34 +0200, Aleksandar Ristovski wrote:
> --- gdb/solib.c	30 Aug 2011 02:48:05 -0000	1.153
> +++ gdb/solib.c	1 Sep 2011 19:56:37 -0000
> @@ -633,6 +633,23 @@ solib_read_symbols (struct so_list *so, 
>    return 0;
>  }
>  
> +/* Return 1 if KNOWN->objfile is used by any other so_list object in the
> +   HEAD list.  Return 0 otherwise.  */
> +
> +static int
> +used (const struct so_list *const known, const struct so_list *const head)
> +{
> +  const struct so_list *pivot;
> +  int found = 0;
> +
> +  for (pivot = head; pivot != NULL && !found; pivot = pivot->next)
> +    {
> +      if (pivot != known && pivot->objfile == known->objfile)
> +	found = 1;
> +    }
> +  return found;
> +}

static int
solist_used (const struct so_list *const known)
{
  const struct so_list *so;

  for (so = so_list_head; so != NULL; so = so->next)
    if (so != known && so->objfile == known->objfile)
      return 1;

  return 0;
}
(untested for consts)

I find both the `head' (we are on solib.c) and `found' variables needless
there.

Use some solib-identifying name (such as the common solib_ prefix).

OK without the `head' parameter and with the solib_ prefix.

GNU/Linux compatible testcase is probably not possible, one would need two
loaded solibs with the same vaddr of their `.text' section.


Thanks,
Jan


  reply	other threads:[~2011-09-02 20:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-31 20:01 Aleksandar Ristovski
2011-08-31 20:12 ` Aleksandar Ristovski
2011-09-02 13:52   ` Aleksandar Ristovski
2011-09-02 20:45     ` Jan Kratochvil [this message]
2011-09-12 21:18       ` Aleksandar Ristovski

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=20110902201715.GA16280@host1.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=aristovski@qnx.com \
    --cc=gdb-patches@sources.redhat.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