From patchwork Sat Oct 27 04:27:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Miller X-Patchwork-Id: 194601 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 2F53F2C00B5 for ; Sat, 27 Oct 2012 15:27:45 +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=1351916867; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Date: Message-Id:To:CC:Subject:From:Mime-Version:Content-Type: Content-Transfer-Encoding:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=AQMoLwvUvzDyLk0MMOd7Sqsuqso=; b=LLJbc955n9Gs0gX Zm+af5R4ewkvwn7w9Fuzxe8RY7EFgiq+s4TMEdrNIW5/0FSC/jj/vJWRLXclLNXD oSn+JwG8aI3Lo0FMWDCKBEfI2VhRTtl94TfP185FJ1bf2beOD8pTT1H2SiP+z2hn ATdudgBlPyYwzU9uCXyBOxo+fl2s= 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:Date:Message-Id:To:CC:Subject:From:Mime-Version:Content-Type:Content-Transfer-Encoding:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=lWE3M0aVMD3t9M55HwXNInZbItgO/GcTAGSAd3c82NKI6RPYL4JsFjAx/z5YM3 ftlsH8YVQsqWqnafG9AawC4+uCPzyXaB9tYUWz+GFZd1zgSJ13pVTXMQ4vtKg3vx P8FkBB25YhvRimd/4RY2DkeC1Di5io93UccFM3a7qE/y0=; Received: (qmail 9922 invoked by alias); 27 Oct 2012 04:27:39 -0000 Received: (qmail 9855 invoked by uid 22791); 27 Oct 2012 04:27:34 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from shards.monkeyblade.net (HELO shards.monkeyblade.net) (149.20.54.216) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 27 Oct 2012 04:27:27 +0000 Received: from localhost (cpe-66-108-116-58.nyc.res.rr.com [66.108.116.58]) by shards.monkeyblade.net (Postfix) with ESMTPSA id 05C75584529; Fri, 26 Oct 2012 21:27:28 -0700 (PDT) Date: Sat, 27 Oct 2012 00:27:24 -0400 (EDT) Message-Id: <20121027.002724.1098296946918586594.davem@davemloft.net> To: gcc-patches@gcc.gnu.org CC: iant@google.com Subject: [PATCH] Fix libbacktrace on 32-bit sparc From: David Miller Mime-Version: 1.0 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'm getting a SIGBUS on every backtrace libbacktrace generates on 32-bit sparc builds. The crashes usually happen in add_function_range(), where 'p' is not 8-byte aligned. It seems that the vector code doesn't take care to align the pointers it returns. I cribbed the size alignment done in mmap.c's implementation of backtrace_alloc() to fix this. Ok to install? libbacktrace/ 2012-10-26 David S. Miller * alloc.c (backtrace_vector_grow): Round size up to a multiple of 8. * mmap.c (backtrace_vector_grow): Likewise. diff --git a/libbacktrace/alloc.c b/libbacktrace/alloc.c index 501f386..59072ed 100644 --- a/libbacktrace/alloc.c +++ b/libbacktrace/alloc.c @@ -78,6 +78,10 @@ backtrace_vector_grow (struct backtrace_state *state ATTRIBUTE_UNUSED, { void *ret; + /* Round for alignment; we assume that no type we care about + is more than 8 bytes. */ + size = (size + 7) & ~ (size_t) 7; + if (size > vec->alc) { size_t alc; diff --git a/libbacktrace/mmap.c b/libbacktrace/mmap.c index e07810d..6e51a0d 100644 --- a/libbacktrace/mmap.c +++ b/libbacktrace/mmap.c @@ -175,6 +175,10 @@ backtrace_vector_grow (struct backtrace_state *state,size_t size, { void *ret; + /* Round for alignment; we assume that no type we care about + is more than 8 bytes. */ + size = (size + 7) & ~ (size_t) 7; + if (size > vec->alc) { size_t pagesize;