From patchwork Thu May 26 18:28:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 97608 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 230A0B6F70 for ; Fri, 27 May 2011 04:28:57 +1000 (EST) Received: (qmail 11968 invoked by alias); 26 May 2011 18:28:56 -0000 Received: (qmail 11958 invoked by uid 22791); 26 May 2011 18:28:55 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_CX, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 26 May 2011 18:28:38 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p4QISbhG019227 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 26 May 2011 14:28:37 -0400 Received: from [127.0.0.1] (ovpn-113-23.phx2.redhat.com [10.3.113.23]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p4QISbm6010228 for ; Thu, 26 May 2011 14:28:37 -0400 Message-ID: <4DDE9BD4.5000306@redhat.com> Date: Thu, 26 May 2011 14:28:36 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/48211 (ICE in gc code) 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 The problem in this PR was that we had a cxx_binding embedded in another object and then put a pointer to the cxx_binding in another gc-able object. So when GC ran we tried to mark the cxx_binding and crash, because it wasn't allocated separately. Conveniently, the fix to allocate it separately makes the code simpler. Tested x86_64-pc-linux-gnu, applying to trunk. commit 47d35e93b23a66a5bb43614875c7ad772e2eb4c5 Author: Jason Merrill Date: Thu May 26 12:59:47 2011 -0400 PR c++/48211 * name-lookup.h (cp_class_binding): Make base a pointer. * name-lookup.c (new_class_binding): Adjust. (poplevel_class): Adjust. diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index bb6d4b9..935dd2a 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -319,33 +319,11 @@ new_class_binding (tree name, tree value, tree type, cxx_scope *scope) cp_class_binding *cb; cxx_binding *binding; - if (VEC_length (cp_class_binding, scope->class_shadowed)) - { - cp_class_binding *old_base; - old_base = VEC_index (cp_class_binding, scope->class_shadowed, 0); - if (VEC_reserve (cp_class_binding, gc, scope->class_shadowed, 1)) - { - /* Fixup the current bindings, as they might have moved. */ - size_t i; - - FOR_EACH_VEC_ELT (cp_class_binding, scope->class_shadowed, i, cb) - { - cxx_binding **b; - b = &IDENTIFIER_BINDING (cb->identifier); - while (*b != &old_base[i].base) - b = &((*b)->previous); - *b = &cb->base; - } - } - cb = VEC_quick_push (cp_class_binding, scope->class_shadowed, NULL); - } - else cb = VEC_safe_push (cp_class_binding, gc, scope->class_shadowed, NULL); cb->identifier = name; - binding = &cb->base; + cb->base = binding = cxx_binding_make (value, type); binding->scope = scope; - cxx_binding_init (binding, value, type); return binding; } @@ -2725,7 +2703,10 @@ poplevel_class (void) if (level->class_shadowed) { FOR_EACH_VEC_ELT (cp_class_binding, level->class_shadowed, i, cb) - IDENTIFIER_BINDING (cb->identifier) = cb->base.previous; + { + IDENTIFIER_BINDING (cb->identifier) = cb->base->previous; + cxx_binding_free (cb->base); + } ggc_free (level->class_shadowed); level->class_shadowed = NULL; } diff --git a/gcc/cp/name-lookup.h b/gcc/cp/name-lookup.h index 4bf253f..3309f0a 100644 --- a/gcc/cp/name-lookup.h +++ b/gcc/cp/name-lookup.h @@ -140,7 +140,7 @@ typedef enum tag_scope { } tag_scope; typedef struct GTY(()) cp_class_binding { - cxx_binding base; + cxx_binding *base; /* The bound name. */ tree identifier; } cp_class_binding;