From patchwork Thu Jun 22 14:46:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 779552 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 3wtktc6X4cz9t0F for ; Fri, 23 Jun 2017 00:46:48 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="JOURyt4m"; 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 :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=tJPJh4mWRgenoMkm39bo66hGJpyWkBGuGyHtEfFAUJ+sY5 ljkwHQ85KbbZA6bkZKoqczcUGKswqmOdClXWR9v97cVt8LeCBKT2mf3I+8qUgOEG zrp6osXCMTZ7NWXTq9NZiL2cS23022XnwTfIOSXq29yQjY4Pqv70GtJ1UTNHo= 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 :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=ODEczxKsx1tJiJHdGkuCrcPEQyk=; b=JOURyt4mLZY+EkYQaClM Nt2zGDysSM1JKiDeBCm/+bIWRfRZgdu1xJWu5IsBphbn/O89gsV02ZXhBHfCJtyr oG0/Up0ukdcCmaibOrmI8H2Udqun1W9gB2o8IJ9SopZeeuj5Nko/117MusVexbiZ aUdBdYfkWLriHgxrMpYlVpQ= Received: (qmail 59392 invoked by alias); 22 Jun 2017 14:46:20 -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 59165 invoked by uid 89); 22 Jun 2017 14:46:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=SHOULD, panic, HERE X-HELO: mail-oi0-f41.google.com Received: from mail-oi0-f41.google.com (HELO mail-oi0-f41.google.com) (209.85.218.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Jun 2017 14:46:17 +0000 Received: by mail-oi0-f41.google.com with SMTP id p66so10126684oia.0 for ; Thu, 22 Jun 2017 07:46:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=xoKZUp5QKyUZnBrsK7ofTuJmD6Y4ADVbn/H3LxkBAW8=; b=UParRWyTyRNdqm5139RvRiBXGs3muObknOALv3QVA2vom2xBUa6IcoF1UT844Qm0hf JiiKJ7G8ILv6+PXGRslg2bQS7R3avwv7A+Qa4DeScBkPdySPeIy1fsPsOlscc4bSV13G 20XwyIM/aa0oWmyUdEy38cRe9u3FHTb7Pio3yNx/wK9xLvhMjdO0wtyIXKNP5gvWD6NG mmQCLxbcLOHVvX6am8/3kq3oVuGZzXqdRw8FznlKRQmNTXD/9WHiHgHenbgQfjPGxN6I BkZBnZMqme6zG1yhqnEJGiZ8gdPtrmSV97ZlmME8qcYGg/bp+yb554KSR77fcRFaODP0 8Fzg== X-Gm-Message-State: AKS2vOwS79vih5S3a969PZ69o2fhTlrNOhjyRQIBFeQKygqB6Viol3ri FzDi7wcLMZZ6t7W+wEhFr/fPDbOvYH/JLwY= X-Received: by 10.202.207.68 with SMTP id f65mr1549091oig.21.1498142775341; Thu, 22 Jun 2017 07:46:15 -0700 (PDT) MIME-Version: 1.0 Received: by 10.202.217.87 with HTTP; Thu, 22 Jun 2017 07:46:14 -0700 (PDT) From: Ian Lance Taylor Date: Thu, 22 Jun 2017 07:46:14 -0700 Message-ID: Subject: libgo patch committed: Don't assume that _ = *s will panic if s is nil To: gcc-patches , "gofrontend-dev@googlegroups.com" With the gc toolchain apparently var s *string _ = *s is enough to panic with a nil pointer dereference. The gccgo compiler will simply discard the dereference, which I think is a reasonable and acceptable optimization. Change the tests to use an exported variable instead. The tests are not currently run, but they will be with a later patch to gotools. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian Index: gcc/go/gofrontend/MERGE =================================================================== --- gcc/go/gofrontend/MERGE (revision 249561) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -b5c9fe259ec43f8079581c3bea0f1d12d85213a7 +8804c912363320e0c229c5a471fb6f4b9e5965e6 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: libgo/go/runtime/testdata/testprog/crash.go =================================================================== --- libgo/go/runtime/testdata/testprog/crash.go (revision 249205) +++ libgo/go/runtime/testdata/testprog/crash.go (working copy) @@ -13,6 +13,8 @@ func init() { register("Crash", Crash) } +var NilPointer *string + func test(name string) { defer func() { if x := recover(); x != nil { @@ -21,8 +23,7 @@ func test(name string) { fmt.Printf(" done\n") }() fmt.Printf("%s:", name) - var s *string - _ = *s + *NilPointer = name fmt.Print("SHOULD NOT BE HERE") } Index: libgo/go/runtime/testdata/testprogcgo/crash.go =================================================================== --- libgo/go/runtime/testdata/testprogcgo/crash.go (revision 249205) +++ libgo/go/runtime/testdata/testprogcgo/crash.go (working copy) @@ -13,6 +13,8 @@ func init() { register("Crash", Crash) } +var NilPointer *string + func test(name string) { defer func() { if x := recover(); x != nil { @@ -21,8 +23,7 @@ func test(name string) { fmt.Printf(" done\n") }() fmt.Printf("%s:", name) - var s *string - _ = *s + *NilPointer = name fmt.Print("SHOULD NOT BE HERE") }