From patchwork Fri Feb 10 15:55:41 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 140680 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 9ADD1B6EF1 for ; Sat, 11 Feb 2012 02:56:01 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1329494162; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:From:To:Subject:Date:Message-ID:User-Agent: MIME-Version:Content-Type:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=DmU6fRswvx5ex+dwxq06kkexm34=; b=LiDmptwAjSkjGaN lxXybdYMGzOBtA/nTnTz/8IdwmqrCpEhF5MUHbU95KxKvgIXx4M2yVaXdTADW9Ds TjainWqwzcV5qq+JAeD9UhDU2vACWSRvv9OKxUwLgGC/7m5YjjZw33EKpJlKoGK4 WLCS/11jivh3tRVFMRbvPI9HA8I8= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version:Content-Type:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=q3cg3t/mf1I4IqooR84ds9it0YSoT8F1fX7VamuoiAysmGThv2mVlv59GCtMZn Gifefn8ZvCLxM1wjiVS+UMTmWVor5Xepy3QOgIszSFqqfJDcXmboW0hyKTMQx6ql v8JKhPhxA5G0BPBQONNe2dJ0/U9i366+JEno5/M5f9XdY=; Received: (qmail 20115 invoked by alias); 10 Feb 2012 15:55:57 -0000 Received: (qmail 20101 invoked by uid 22791); 10 Feb 2012 15:55:56 -0000 X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_LOW, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from mail-pz0-f47.google.com (HELO mail-pz0-f47.google.com) (209.85.210.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 10 Feb 2012 15:55:43 +0000 Received: by daln34 with SMTP id n34so2307128dal.20 for ; Fri, 10 Feb 2012 07:55:43 -0800 (PST) Received: by 10.68.138.167 with SMTP id qr7mr17861045pbb.0.1328889343579; Fri, 10 Feb 2012 07:55:43 -0800 (PST) Received: by 10.68.138.167 with SMTP id qr7mr17861023pbb.0.1328889343491; Fri, 10 Feb 2012 07:55:43 -0800 (PST) Received: from coign.google.com ([2620:0:1000:2301:f2de:f1ff:fe40:72a8]) by mx.google.com with ESMTPS id b4sm11577938pbc.7.2012.02.10.07.55.42 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 10 Feb 2012 07:55:42 -0800 (PST) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: libgo patch committed: Record g0 top of stack correctly when not split Date: Fri, 10 Feb 2012 07:55:41 -0800 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-Gm-Message-State: ALoCoQliBWRSbZfSnpYEOIqlwU8B8RD3xbjNfYgI9t9fW9TKjs8YgqJn1RXtRvOvqAlCo3eoqhBjyo3YGRr6oE0aI9jZA2lRrvxT0jsVaGzpyRrmtcrT3pNHWuD9kp7RJqVccrnXN7wYoh4/6GqV3ppc7oklMJ7Hj05LsB7uuDf2OZ/Ntyf1TRE= 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 This patch to libgo records the top of the g0 goroutine stack correctly when not using -fsplit-stack. Without this patch the garbage collector would scan beyond the top of the stack when looking at the g0 stack, which could cause segmentation violations. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r 971ec6345e64 libgo/runtime/proc.c --- a/libgo/runtime/proc.c Fri Feb 10 07:50:54 2012 -0800 +++ b/libgo/runtime/proc.c Fri Feb 10 07:52:48 2012 -0800 @@ -909,7 +909,9 @@ __splitstack_getcontext(&g->stack_context[0]); #else g->gcinitial_sp = ∓ - g->gcstack_size = StackMin; + // Setting gcstack_size to 0 is a marker meaning that gcinitial_sp + // is the top of the stack, not the bottom. + g->gcstack_size = 0; g->gcnext_sp = ∓ #endif getcontext(&g->context); @@ -1267,6 +1269,8 @@ #else sp = newg->gcinitial_sp; spsize = newg->gcstack_size; + if(spsize == 0) + runtime_throw("bad spsize in __go_go"); newg->gcnext_sp = sp; #endif } else {