From patchwork Thu Dec 31 09:17:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 561867 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 3E77E140BA3 for ; Thu, 31 Dec 2015 20:17:49 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=UrUODpN8; dkim-atps=neutral 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:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=pNJ6fF21E8of4H+hiDYFctEeIiWnN Z24eXhKveogzXvLe3ubAnjRapzKnLZiovUgOe6j3zvEJRQt1lpaN/htP7rFRnfHU 9wVedibzrQ2nu5zwUnxwEvzNNq2VYRh7UG+A5vXNmqeON3k73LyCiSYF1nWTLdsY TJCEstX43KwbqY= 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:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=+3Z1m0r+O7PuNfwZ8bi2wCfXMgA=; b=UrU ODpN8fGorEpfMZNciaS9WefNfNgrIjstPWn9zGL4/w+zIrnJY60zmyaHq5ASgZUL qNobmLYeAtn8pEcK++H62qk3qbAhTlPxZl5Kyt7Qr9KAl8Ul7Bb/wQuwOPslvdi7 tNzPfqsnpEqMNdS2j1dUYCnk5rTbuEHigtLvI+2Y= Received: (qmail 125620 invoked by alias); 31 Dec 2015 09:17:42 -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 125597 invoked by uid 89); 31 Dec 2015 09:17:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.5 required=5.0 tests=AWL, BAYES_50, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=handlers, jakubredhatcom, sk:jakub@r, jakub@redhat.com X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 31 Dec 2015 09:17:40 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 6C06E8E229; Thu, 31 Dec 2015 09:17:39 +0000 (UTC) Received: from tucnak.zalov.cz ([10.3.113.3]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tBV9Hbcu023431 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 31 Dec 2015 04:17:39 -0500 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id tBV9HZ4U029643; Thu, 31 Dec 2015 10:17:36 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id tBV9HYc9029642; Thu, 31 Dec 2015 10:17:34 +0100 Date: Thu, 31 Dec 2015 10:17:34 +0100 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix ubsan ICE with non-C/C++ FEs (PR sanitizer/69055) Message-ID: <20151231091734.GX18720@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes Hi! ubsan_instrument_float_cast is called from convert.c, therefore for all FEs that uses convert.c. For C/C++, the ubsan builtins are already initialized through their inclusion from builtins.def, but for other builtins they can be still uninitialized. This patch adds a call that ensures the builtins are initialized when we need them in ubsan_instrument_float_cast. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/5? 2015-12-31 Jakub Jelinek PR sanitizer/69055 * ubsan.c (ubsan_instrument_float_cast): Call initialize_sanitizer_builtins. * gfortran.dg/pr69055.f90: New test. Jakub --- gcc/ubsan.c.jj 2015-11-09 13:39:32.000000000 +0100 +++ gcc/ubsan.c 2015-12-28 10:22:23.024610469 +0100 @@ -1588,6 +1588,7 @@ ubsan_instrument_float_cast (location_t { location_t *loc_ptr = NULL; unsigned num_locations = 0; + initialize_sanitizer_builtins (); /* Figure out if we can propagate location to ubsan_data and use new style handlers in libubsan. */ if (ubsan_use_new_style_p (loc)) --- gcc/testsuite/gfortran.dg/pr69055.f90.jj 2015-12-28 10:28:58.925048460 +0100 +++ gcc/testsuite/gfortran.dg/pr69055.f90 2015-12-28 10:28:53.082130547 +0100 @@ -0,0 +1,10 @@ +! { dg-do compile } +! { dg-options "-fsanitize=float-cast-overflow" } + +subroutine pr69055 + implicit none + integer :: n + real(8) :: b + b = huge(1.0D0) + n = b +end subroutine pr69055