From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11156 invoked by alias); 8 Jan 2013 10:17:52 -0000 Received: (qmail 11048 invoked by uid 48); 8 Jan 2013 10:17:21 -0000 From: "rguenth at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: bootstrap X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.8.0 X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2013-01/txt/msg00628.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55792 --- Comment #15 from Richard Biener 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. */ > > > > template > > void > > gt_ggc_mx (vec *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_ (void *x_p) > { > vec * const x = (vec *)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[] = { ... { <o_global_var_decls, 1, sizeof (lto_global_var_decls), >_ggc_mx_vec_tree_va_gc_, >_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 * const x = (vec *)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 void gt_ggc_mx (vec *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?