From patchwork Mon Apr 22 16:11:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 238607 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id B42DC2C0149 for ; Tue, 23 Apr 2013 02:11:40 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=CV0sWKF6+mnDy6ZFwGVmaslHPi41+uCG9ql5zbh9b+weM2qZ6ZSdB /5wZJjN/G8gxE42e9lwpviFOTaImOABTBpDhxX2ycoDr28U4oV3322Nmxr1I4nQt u/QQtT9WSr8AaguZfJVBkuXwHe6CIFrg8Fhy5+XP4piyqByI+hodww= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=AZxAu3an4BZHxMqOga032TKDhXQ=; b=cn31dxfkOuhGYCn2sA2h /RyEz1HCu5snanVke4OgLDHIjYOUt4nbcEanFf8OwMUhIRFjN9E5iLWUGqh0JE1G 0dTtzhtzeEXqeSDraDH6hp1r2HgMKZQhKWKTXtkHnIInf/ah92I5HOXGE+HHLlKM LwyHHmpKANTSMwJN952wFCc= Received: (qmail 25459 invoked by alias); 22 Apr 2013 16:11:33 -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 25444 invoked by uid 89); 22 Apr 2013 16:11:32 -0000 X-Spam-SWARE-Status: No, score=-6.9 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 22 Apr 2013 16:11:32 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3MGBUKn021080 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 22 Apr 2013 12:11:30 -0400 Received: from redhat.com (ovpn-116-41.ams2.redhat.com [10.36.116.41]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r3MGBR2t013565 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Mon, 22 Apr 2013 12:11:29 -0400 Date: Mon, 22 Apr 2013 18:11:26 +0200 From: Marek Polacek To: GCC Patches Subject: [PATCH] Fix PR56990 Message-ID: <20130422161126.GH13346@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) We're getting SIGFPE, because one simply does not divide by zero. Fixed by doing the modulo only when size != 0. Regtested/bootstrapped on x86_64-linux, ok for trunk and 4.8? 2013-04-22 Marek Polacek PR sanitizer/56990 * tsan.c (instrument_expr): Don't count modulo if the size is zero. * gcc.dg/pr56990.c: New test. Marek --- gcc/tsan.c.mp 2013-04-19 15:39:46.416450528 +0200 +++ gcc/tsan.c 2013-04-22 17:23:54.115647673 +0200 @@ -131,7 +131,8 @@ instrument_expr (gimple_stmt_iterator gs if (TREE_READONLY (base)) return false; - if (bitpos % (size * BITS_PER_UNIT) + if ((size != 0 + && bitpos % (size * BITS_PER_UNIT)) || bitsize != size * BITS_PER_UNIT) return false; --- gcc/testsuite/gcc.dg/pr56990.c.mp 2013-04-22 17:30:14.523876683 +0200 +++ gcc/testsuite/gcc.dg/pr56990.c 2013-04-22 17:29:06.704666252 +0200 @@ -0,0 +1,10 @@ +/* PR sanitizer/56990 */ +/* { dg-do compile { target { x86_64-*-linux* && lp64 } } } */ +/* { dg-options "-fsanitize=thread" } */ + +struct S{}; + +void foo(struct S *p) +{ + *p = (struct S){}; +}