From patchwork Thu Jan 31 16:41:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 217211 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 923882C0086 for ; Fri, 1 Feb 2013 03:41:39 +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=1360255300; h=Comment: DomainKey-Signature: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=tAJ1mq6 wthle6RFM3otLY3FaoKE=; b=IVOa6E/5eoD2cSRTqsESbsurb5WkiNvJyngNEjT t9aU4AM1HvfQah/fAjzF45vMGbA0LQuY8chc6KROKx5ixMOkD/H7UlrVZFcfJWe2 nqcWozL2wxXCKYr43ceFcHffqXrNv7lfLblVXUJGvWayNpkyJYVXPt+WV7Gd+zY1 zANo= 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:X-Google-DKIM-Signature:X-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=rfxiRCRyiltMYPEA76W3zMlhd2aYlHyQ8Kz4/JkoDVSNctyvSBFlpSS3DiwFog MB0itptKeHRTro1/NFobpAX1RzKZy11AZ0u5tqB9CxSIZ5n9im8X8LqPQ7H972L/ N6EmHYwyyEQ9uhqmloy3oNxvZD+aFwDpsJnj/hCsQG43s=; Received: (qmail 31726 invoked by alias); 31 Jan 2013 16:41:30 -0000 Received: (qmail 31618 invoked by uid 22791); 31 Jan 2013 16:41:26 -0000 X-SWARE-Spam-Status: No, hits=-5.3 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from mail-pa0-f46.google.com (HELO mail-pa0-f46.google.com) (209.85.220.46) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 31 Jan 2013 16:41:22 +0000 Received: by mail-pa0-f46.google.com with SMTP id kp14so1801257pab.19 for ; Thu, 31 Jan 2013 08:41:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:subject:date:message-id:user-agent:mime-version :content-type:x-gm-message-state; bh=auGceftKnrwc20hKMCxi2ERnuCqyysE4GYE9WxqX57w=; b=HDXoEE8wdW+UdUZ1JpTuJEsMqly3Nb66IZ7DtFRSiwme+YwMzeIZ4h2HdfKaXuElDj bKUvrfN42i7GoxoBq2AOyJKxJub5uA4f1+B4gWmEUjxG2anwJs3O0omoMFBRuzCn/yI7 VxXw7avWg0TjNtUky9PciXW92HGyLK9BnCu+HJaSEWp5PnmjmMH3B2ur4WuooiZV61sI hGRCjFh35iiHEMHt+4GBPMrcDbmx6vG0+HdKtgg48XfBMbJ2poAA42SfTeu0JaX1Dtlq mZx/+POhvYIJauEcMjmEU7U4HcbF2+3nCUkc3gi77wABPNmdpN8j95f5UTxnzziYXEO/ Kh9Q== X-Received: by 10.68.235.1 with SMTP id ui1mr23755713pbc.138.1359650481452; Thu, 31 Jan 2013 08:41:21 -0800 (PST) Received: from iant-glaptop.google.com ([172.26.54.189]) by mx.google.com with ESMTPS id az8sm6076564pab.3.2013.01.31.08.41.19 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 31 Jan 2013 08:41:20 -0800 (PST) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: libgo patch committed: Don't allocate during backtrace Date: Thu, 31 Jan 2013 08:41:17 -0800 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 X-Gm-Message-State: ALoCoQnfHAuOTKnwMadol8Euhu0QBZblJu77uRSDfZ7Bpnig4fiqqu+8bOJay35vzT/UFdUsWf5UPa08fIbAomJjurZc3jrD+xVOheYaaXWqNkPZ+NckAGjPlu2oWHeEiy+Vyu4Jq9Dh53NxIw5VJGc+u1zf7P4kds34HZwINA5Je+md2x3RngjMP149pAy4Ny1pnDchE1QG 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 The libbacktrace interfaces says that the strings passed to the callback routine may disappear. As it happens, in the current implementation they will not. The Go backtrace routine needs to hang on to the strings, and I've discovered that it can't reliably allocate memory, since it might be called in the middle of an existing memory allocation. So at least for now just assume that the backtrace strings will hang around. I'll fix this if I can figure out a way to allocate memory there. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r 368d10817c19 libgo/runtime/go-callers.c --- a/libgo/runtime/go-callers.c Wed Jan 30 14:00:04 2013 -0800 +++ b/libgo/runtime/go-callers.c Thu Jan 31 08:38:26 2013 -0800 @@ -43,8 +43,14 @@ loc = &arg->locbuf[arg->index]; loc->pc = pc; - loc->filename = runtime_gostring ((const byte *) filename); - loc->function = runtime_gostring ((const byte *) function); + + /* The libbacktrace library says that these strings might disappear, + but with the current implementation they won't. We can't easily + allocate memory here, so for now assume that we can save a + pointer to the strings. */ + loc->filename = runtime_gostringnocopy ((const byte *) filename); + loc->function = runtime_gostringnocopy ((const byte *) function); + loc->lineno = lineno; ++arg->index; return arg->index >= arg->max;