public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug bootstrap/55792] [4.8 Regression] Bad memory access with profiledbootstrap and LTO
Date: Tue, 08 Jan 2013 10:17:00 -0000	[thread overview]
Message-ID: <bug-55792-4-vYMKmmIVjJ@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-55792-4@http.gcc.gnu.org/bugzilla/>


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55792

--- Comment #15 from Richard Biener <rguenth at gcc dot gnu.org> 2013-01-08 10:17:16 UTC ---
(In reply to comment #11)
> (In reply to comment #9)
> > Eh.  Diego, how does GTY((user)) work here?  It smells like a bug in vec.h
> > to me.
> > 
> > /* Garbage collection support for vec<T, A, vl_embed>.  */
> > 
> > template<typename T>
> > void
> > gt_ggc_mx (vec<T, va_gc> *v)
> > {
> >   extern void gt_ggc_mx (T &);
> >   for (unsigned i = 0; i < v->length (); i++)
> >     gt_ggc_mx ((*v)[i]);
> > }
> > 
> > doesn't it need to mark the vec itself?  Maybe automatic registration of
> > roots (this is a GC root) does not work with GTY((user))?
> 
> No.  The root is/should be marked by the code calling gt_ggc_mx.  gengtype will
> generate code like:
> 
>   if (ggc_test_and_set_mark (x))
>     {
>       gt_ggc_mx (x);
>     }
> 
> ggc_test_and_set_mark() is the one that marks the root.  Has gengtype generated
> a function for this global?  It should be something like this
> 
> void
> gt_ggc_mx_vec_<mangled_type_name> (void *x_p)
> {
>   vec<type_name,va_gc> * const x = (vec<type_name,va_gc> *)x_p;
>   if (ggc_test_and_set_mark (x))
>     {
>       gt_ggc_mx (x);
>     }
> }

There is

EXPORTED_CONST struct ggc_root_tab gt_ggc_r_gtype_desc_c[] = {
...
  {
    &lto_global_var_decls,
    1,
    sizeof (lto_global_var_decls),
    &gt_ggc_mx_vec_tree_va_gc_,
    &gt_pch_nx_vec_tree_va_gc_
  },

in gtype-desc.c, which looks like

void
gt_ggc_mx_vec_tree_va_gc_ (void *x_p)
{
  vec<tree,va_gc> * const x = (vec<tree,va_gc> *)x_p;
  if (ggc_test_and_set_mark (x))
    {
      gt_ggc_mx (x);
    }
}

with

/* If EXPR is not NULL and previously unmarked, mark it and evaluate
   to true.  Otherwise evaluate to false.  */
#define ggc_test_and_set_mark(EXPR) \
  ((EXPR) != NULL && ((void *) (EXPR)) != (void *) 1 && ! ggc_set_mark (EXPR))

this indeed looks correct to me given vec.h's

template<typename T>
void
gt_ggc_mx (vec<T, va_gc> *v)
{
  extern void gt_ggc_mx (T &);
  for (unsigned i = 0; i < v->length (); i++)
    gt_ggc_mx ((*v)[i]);
}

and the generated(?)

void
gt_ggc_mx (union tree_node *& x)
{
  if (x)
    gt_ggc_mx_lang_tree_node ((void *) x);
}

So I'm still not sure what HJ means with "it's collected".  GC roots are
never collected.  HJ, should your patch fix anything?  What do you think
the bug is?


  parent reply	other threads:[~2013-01-08 10:17 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-22 18:05 [Bug bootstrap/55792] New: " hjl.tools at gmail dot com
2012-12-22 18:43 ` [Bug bootstrap/55792] " hjl.tools at gmail dot com
2012-12-22 20:13 ` hjl.tools at gmail dot com
2013-01-03 19:03 ` hjl.tools at gmail dot com
2013-01-04 23:58 ` hjl.tools at gmail dot com
2013-01-05 16:47 ` hjl.tools at gmail dot com
2013-01-05 17:21 ` hjl.tools at gmail dot com
2013-01-07 10:13 ` rguenth at gcc dot gnu.org
2013-01-07 15:41 ` hjl.tools at gmail dot com
2013-01-07 16:02 ` rguenth at gcc dot gnu.org
2013-01-07 16:03 ` [Bug bootstrap/55792] [4.8 Regression] " rguenth at gcc dot gnu.org
2013-01-07 17:55 ` dnovillo at gcc dot gnu.org
2013-01-07 22:14 ` hjl.tools at gmail dot com
2013-01-07 23:30 ` hjl.tools at gmail dot com
2013-01-08  1:20 ` hjl.tools at gmail dot com
2013-01-08 10:17 ` rguenth at gcc dot gnu.org [this message]
2013-01-08 17:13 ` hjl.tools at gmail dot com
2013-01-09  0:23 ` hjl.tools at gmail dot com
2013-01-09  9:32 ` rguenth at gcc dot gnu.org
2013-01-09 16:11 ` hjl.tools at gmail dot com
2013-01-09 17:13 ` hjl.tools at gmail dot com
2013-01-09 18:22 ` rguenth at gcc dot gnu.org
2013-01-09 18:38 ` hjl.tools at gmail dot com
2013-01-09 22:52 ` hjl.tools at gmail dot com
2013-01-10 11:30 ` rguenth at gcc dot gnu.org
2013-01-10 12:16 ` rguenth at gcc dot gnu.org
2013-01-10 13:43 ` rguenth at gcc dot gnu.org
2013-01-10 14:08 ` rguenth at gcc dot gnu.org
2013-01-10 14:12 ` rguenth at gcc dot gnu.org
2013-01-10 15:29 ` rguenth at gcc dot gnu.org
2013-01-10 15:35 ` rguenth at gcc dot gnu.org
2013-01-10 17:03 ` hjl.tools at gmail dot com
2013-01-10 19:36 ` hjl.tools at gmail dot com
2013-01-11 17:37 ` hubicka at ucw dot cz
2013-01-14 13:43 ` rguenth at gcc dot gnu.org
2013-01-14 13:50 ` rguenth at gcc dot gnu.org
2013-01-14 13:51 ` rguenth at gcc dot gnu.org
2013-01-15 14:32 ` rguenth at gcc dot gnu.org

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=bug-55792-4-vYMKmmIVjJ@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).