From patchwork Mon Nov 7 07:53:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xinliang David Li X-Patchwork-Id: 124013 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id A5FDB1007D3 for ; Mon, 7 Nov 2011 18:53:31 +1100 (EST) Received: (qmail 32209 invoked by alias); 7 Nov 2011 07:53:28 -0000 Received: (qmail 32201 invoked by uid 22791); 7 Nov 2011 07:53:27 -0000 X-SWARE-Spam-Status: No, hits=-3.7 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-yw0-f47.google.com (HELO mail-yw0-f47.google.com) (209.85.213.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 07 Nov 2011 07:53:14 +0000 Received: by ywf9 with SMTP id 9so5536781ywf.20 for ; Sun, 06 Nov 2011 23:53:14 -0800 (PST) Received: by 10.236.124.51 with SMTP id w39mr32298721yhh.95.1320652394087; Sun, 06 Nov 2011 23:53:14 -0800 (PST) MIME-Version: 1.0 Received: by 10.236.124.51 with SMTP id w39mr32298708yhh.95.1320652393961; Sun, 06 Nov 2011 23:53:13 -0800 (PST) Received: by 10.150.198.10 with HTTP; Sun, 6 Nov 2011 23:53:13 -0800 (PST) Date: Sun, 6 Nov 2011 23:53:13 -0800 Message-ID: Subject: vector garbaged collected while still in use From: Xinliang David Li To: GCC Patches X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org I have seen compiler build error (segmentation fault) in libstdc++-v3. It turns out that a vector allocated in gc memory is GCed before the vector is released. The gc call is from a call to synethesize_method from cp_finish_decl. The following patch fixes the problem. Compiler bootstraps and tested on linux/x86-64. Ok for trunk (or better fix suggested)? thanks, David 2011-11-05 Xinliang David Li * cp/decl.c (cp_finish_decl): Prevent cleanups from being garbage collected before being released. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 181013) +++ cp/decl.c (working copy) @@ -5902,6 +5902,8 @@ value_dependent_init_p (tree init) FLAGS is LOOKUP_ONLYCONVERTING if the = init syntax was used, else 0 if the (init) syntax was used. */ +static GTY (()) VEC(tree,gc) *cleanups_vec; + void cp_finish_decl (tree decl, tree init, bool init_const_expr_p, tree asmspec_tree, int flags) @@ -5914,6 +5916,7 @@ cp_finish_decl (tree decl, tree init, bo bool var_definition_p = false; tree auto_node; + cleanups_vec = cleanups; if (decl == error_mark_node) return; else if (! decl) @@ -6319,6 +6322,7 @@ cp_finish_decl (tree decl, tree init, bo FOR_EACH_VEC_ELT (tree, cleanups, i, t) push_cleanup (decl, t, false); release_tree_vector (cleanups); + cleanups_vec = NULL; if (was_readonly) TREE_READONLY (decl) = 1;