From patchwork Wed Jan 1 06:39:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Stump X-Patchwork-Id: 305936 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 8254C2C0086 for ; Wed, 1 Jan 2014 17:40:11 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :content-type:content-transfer-encoding:subject:date:message-id :cc:to:mime-version; q=dns; s=default; b=jv8eD+r1oBzJwR49ntcA7BF BPg7mZGQ5+c9grX/9CODIE7cnYxl4lNNy/xWm0hdwW9OYMwHv0tVANmRDDCNdJsf ozZIRCoN7ox7lfvjo0fOaMNdiqDbm+jAlvNK/QmvFjCYx7Ie2sNVAzdrNvI0FBe0 ldzLdTk+zt68b62XcdoU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :content-type:content-transfer-encoding:subject:date:message-id :cc:to:mime-version; s=default; bh=jXXyR9xl99pUBlzxYMnQo8Pt+pg=; b= RKKqtZzOWPO2nTJmq8QmawUrvrxtRZzf2Gc8Fff96WKv6SfGNcGuaYGV5sE8fuF8 59whY0NUiD1Kibwkic+2NGwm+wG4HSCSpAAwdxzDrZUIVhh679tDo5UgOkONgdcT 9iEjUDism8WACRXr57SwZicjh8Qjh0hPbPstZ8xbujw= Received: (qmail 9046 invoked by alias); 1 Jan 2014 06:40:04 -0000 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 Received: (qmail 9037 invoked by uid 89); 1 Jan 2014 06:40:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: qmta05.emeryville.ca.mail.comcast.net Received: from qmta05.emeryville.ca.mail.comcast.net (HELO qmta05.emeryville.ca.mail.comcast.net) (76.96.30.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 01 Jan 2014 06:40:02 +0000 Received: from omta15.emeryville.ca.mail.comcast.net ([76.96.30.71]) by qmta05.emeryville.ca.mail.comcast.net with comcast id 8Wef1n0011Y3wxoA5Wg1rc; Wed, 01 Jan 2014 06:40:01 +0000 Received: from up.mrs.kithrup.com ([24.4.193.8]) by omta15.emeryville.ca.mail.comcast.net with comcast id 8Wfz1n00B0BKwT48bWg0t9; Wed, 01 Jan 2014 06:40:00 +0000 From: Mike Stump Subject: pch bug fix Date: Tue, 31 Dec 2013 22:39:58 -0800 Message-Id: Cc: Kenneth Zadeck To: "gcc-patches@gcc.gnu.org List" Mime-Version: 1.0 (Mac OS X Mail 6.6 \(1510\)) X-IsSubscribed: yes In testing for wide-int, we discovered that someone seems to have blown pch. The problem is that the optabs field is not a string. It's size is not determined by strlen. strlen are the semantics gty attaches to unsigned char * data. By defeating the type of optabs to being any other type, then the length is determined by the ggc subsystem which just knows the length of the data (2K on my system). I don't really like the type lying going on. I'd prefer if a tree-core person would get honest with the types. Another style of fix would be to decide that atomic in this case means something else, then, we'd have to have a gty person implement the new semantics. Until that is done, this problem is so bad, that the below should go in until someone can fix gty, if someone doesn't want to be honest with the type system. This bug comes across as a random memory smasher and is incredibly annoying to track down. There is non-determinism in the process and will causes non-deterministic memory crashes, but, only on pch use. To track down why, you have to trace back through the pch writing process and realize the data in memory is completely valid, is it only the meta information about that data that pch uses from the GTY world that causes any problem. Ok? Index: optabs.c =================================================================== --- optabs.c (revision 206086) +++ optabs.c (working copy) @@ -6242,7 +6242,7 @@ /* If the optabs changed, record it. */ if (memcmp (tmp_optabs, this_target_optabs, sizeof (struct target_optabs))) - TREE_OPTIMIZATION_OPTABS (optnode) = (unsigned char *) tmp_optabs; + TREE_OPTIMIZATION_OPTABS (optnode) = (struct target_optabs_S *) tmp_optabs; else { TREE_OPTIMIZATION_OPTABS (optnode) = NULL; Index: tree-core.h =================================================================== --- tree-core.h (revision 206086) +++ tree-core.h (working copy) @@ -1559,6 +1559,9 @@ struct tree_statement_list_node *tail; }; +struct GTY(()) target_optabs_S { + unsigned char e[1]; +}; /* Optimization options used by a function. */ @@ -1570,7 +1573,7 @@ /* Target optabs for this set of optimization options. This is of type `struct target_optabs *'. */ - unsigned char *GTY ((atomic)) optabs; + struct target_optabs_S *GTY((atomic)) optabs; /* The value of this_target_optabs against which the optabs above were generated. */