From patchwork Tue Jan 29 00:49:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 1032420 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-494879-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=golang.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="PDdypXUQ"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=golang-org.20150623.gappssmtp.com header.i=@golang-org.20150623.gappssmtp.com header.b="e9vYUWXm"; dkim-atps=neutral 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 43pSZX1zWJz9sCX for ; Tue, 29 Jan 2019 11:49:56 +1100 (AEDT) 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=MwAX17k9lfur9sF8TnR6GxNDkjY1pz9pBVzjEr9LnHWn/s Z9GAVbZq2vtkEe1DDI+UVQiFMs2gA4i4pJ8I8eztFwQ4fG+DZ1gxLwu9E7gOcGlG Li4NZxGkDP1NbsU8H+rsovr+XXv6B42BUu8pz6BMdTvlEu7JLVzBuHZeDOxao= 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=gaoiNURYy9kiN7ofSHfKPSS4444=; b=PDdypXUQtWw/Q14oCrqd +M9FNaWG1enRqyx3PapeF8iVlZNkRVhOUFRROE9dxCtMMKSN493+unFUQu5vDCUd EJ66FlmRVorQ981Z/vcNU9LyzPri0kqVNk9ZcVCyMBVrJte51cFXuCwsFP+UuYCh TAWympsgnLQyu3/hwqaTnqo= Received: (qmail 97707 invoked by alias); 29 Jan 2019 00:49:44 -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 97622 invoked by uid 89); 29 Jan 2019 00:49:44 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Cherry, cherry X-HELO: mail-lf1-f46.google.com Received: from mail-lf1-f46.google.com (HELO mail-lf1-f46.google.com) (209.85.167.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 29 Jan 2019 00:49:42 +0000 Received: by mail-lf1-f46.google.com with SMTP id f5so13283453lfc.13 for ; Mon, 28 Jan 2019 16:49:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golang-org.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=W+IDM67IpxpxI1VbdnXof+lXL+M0dwUWPcOh7hP7iRs=; b=e9vYUWXmJALefXpLdGyO98c57tM6rq9k6/TOfRc0xml29YJCmrhzasGCA7Y+nccWf9 lxn3sNiwp8qhPpFzyjnK+WcFskmzJP9gkwnkmIHbkFv+lzWcy/o9GZRWHc/2H4Bnp8ye Rib08v4a6hsq0XdBB3LYiSUJwlIqBHfv7sR5GkSCFMDupf3C9ANZ1/WxbEnWMXTDVooA ppr88W5XHDZdoqiaKBjFYH7wLyExvOhdOWrVJeCcx9eruWPDL0rlKv1npUmKwgBw3UOS cR0aEme2RHiFXTFkjwkNNe8gRyMASwuu2GeT0GR9QvapAU5bVr8fvYWA8uGGfCAgUGG9 gbPg== MIME-Version: 1.0 From: Ian Lance Taylor Date: Mon, 28 Jan 2019 16:49:27 -0800 Message-ID: Subject: libgo patch committed: Use the call instruction's PC for panic-in-runtime checks To: gcc-patches , gofrontend-dev This patch by Cherry Zhang changes libgo to use the call instruction's PC for panic-in-runtime detection. If a panic happens in the runtime we turn that into a fatal error. We use the caller's PC to determine if the panic call is inside the runtime. getcallerpc returns the PC immediately after the call instruction. If the call is the very last instruction of a function, it may not find this PC belong to a runtime function, giving false result. We need to back off the PC by 1 to the call instruction. 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 268347) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -5ccb2d8593963e06ec3a35d362b384e82301d9f0 +c2cac0ba0a92e74d5675c3c9f4e53d2567dbc903 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: libgo/go/runtime/panic.go =================================================================== --- libgo/go/runtime/panic.go (revision 268158) +++ libgo/go/runtime/panic.go (working copy) @@ -53,7 +53,7 @@ var indexError = error(errorString("inde // entire runtime stack for easier debugging. func panicindex() { - name, _, _ := funcfileline(getcallerpc(), -1) + name, _, _ := funcfileline(getcallerpc()-1, -1) if hasPrefix(name, "runtime.") { throw(string(indexError.(errorString))) } @@ -64,7 +64,7 @@ func panicindex() { var sliceError = error(errorString("slice bounds out of range")) func panicslice() { - name, _, _ := funcfileline(getcallerpc(), -1) + name, _, _ := funcfileline(getcallerpc()-1, -1) if hasPrefix(name, "runtime.") { throw(string(sliceError.(errorString))) } Index: libgo/runtime/go-runtime-error.c =================================================================== --- libgo/runtime/go-runtime-error.c (revision 268158) +++ libgo/runtime/go-runtime-error.c (working copy) @@ -63,7 +63,7 @@ __go_runtime_error (int32 i) struct funcfileline_return fileline; bool in_runtime; - fileline = runtime_funcfileline ((uintptr) runtime_getcallerpc(), 0); + fileline = runtime_funcfileline ((uintptr) runtime_getcallerpc()-1, 0); in_runtime = (fileline.retfn.len > 0 && (__builtin_strncmp ((const char *) fileline.retfn.str, "runtime.", 8)