From patchwork Mon Jun 12 23:14:15 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: 774886 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 3wmpd11TS5z9s71 for ; Tue, 13 Jun 2017 09:14:28 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="trjt520p"; 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=Q1ukcW1OFWjKtB6LQiUb1RGwDfQ67clLEAVw5h3QTndcZB p5JkHwKGaiCEw3L3RwUUj81b2wp3CKPhW7Rn7YAlN0+A3kSS/Cbt/od0+lHQufVS qkc3WtMGdmeEFDbHruGynCRtbm/o9/A5u5jyqIr+7UCt4cbvT4FCVF2vfOLoI= 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=VIx+sVdm1NtNzvLe/INjwdeSPFk=; b=trjt520pfx3gAxgAb9Pw EE+hD+jKD30b4GAfbJcp/hw51Fju1mcTuZlP8xsznYDXiAVfaJQrbrcaOSraWJPu 8pXv/UBgI2s4K+l2FxRzv7rRmRXUeOPAJNBb+xn0WCuIgZyUSDGXmESd4hts7cb3 81xWslMX3xFRjjjIPWQm92w= Received: (qmail 31639 invoked by alias); 12 Jun 2017 23:14:15 -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 31625 invoked by uid 89); 12 Jun 2017 23:14:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.8 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=UD:Store X-HELO: mail-oi0-f48.google.com Received: from mail-oi0-f48.google.com (HELO mail-oi0-f48.google.com) (209.85.218.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 12 Jun 2017 23:14:13 +0000 Received: by mail-oi0-f48.google.com with SMTP id b6so9451314oia.1 for ; Mon, 12 Jun 2017 16:14:17 -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=9e0IQAWl+SgwppoLftnRtaV1d6syPcfNJFbW2mmkBFQ=; b=nDo8f71eg1llKQV5M3o6KCiX8wXxU0qP3EXdfNiKCPYcaZzK9AmxdozJnmeALwzIDm hu1/UvIDJtQ+8YrdiPTGTblp1FClu4e0lpbPE97jG+Ep3Kt9SicE3/+deMjcVwmxTqWe zQC0PYHsyckaYp7+YRacaJ+QHSdYQuh5J75DsxQgWcvjXeZ9MZpiMi4o4uslC5akRVyU 9fy8816arBvYCs/aGBJfA/r7LiHROsSqeQdKARTIWdVNSkHMv/4n+V/0sHmAwGNBp/WO F9aBuXoNdFjxiJe2FAQCc0ZlWJ+mPR523/F9DuAr3d7Ov/34cxmaHf4D3GBkcyM/t7pD J2kQ== X-Gm-Message-State: AKS2vOzIXLw0Xti/CerUYtamu6K00pWhJJfaUSIfgHfT14sfmdO9YPML mMp3+JETHit5k0i4j8p4KIwQNAN8cmuDKdo= X-Received: by 10.202.207.88 with SMTP id f85mr7981791oig.21.1497309256018; Mon, 12 Jun 2017 16:14:16 -0700 (PDT) MIME-Version: 1.0 Received: by 10.202.207.77 with HTTP; Mon, 12 Jun 2017 16:14:15 -0700 (PDT) From: Ian Lance Taylor Date: Mon, 12 Jun 2017 16:14:15 -0700 Message-ID: Subject: libgo patch committed: ignore _Gscan bit when checking status in CgocallDone To: gcc-patches , "gofrontend-dev@googlegroups.com" This patch to libgo ignores the _Gscan bit when checking status in CgocallDone. It also always access the atomicstatus field atomically. The effect of not checking the _Gscan bit is that if the GC decides to scan the stack just as the goroutine is leaving the system call, the goroutine might fail to call exitsyscall. Then then typically causes a runtime assertion failure later on. If we do call exitsyscall as we should, it will stall (in casgstatus) until the _Gscan bit is cleared. 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 249131) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -61222d34c1b33a369bd86008a0541455dd17727e +908fc7e46ebe36658ed86b65a3d165fccb2e8576 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: libgo/go/runtime/cgo_gccgo.go =================================================================== --- libgo/go/runtime/cgo_gccgo.go (revision 249125) +++ libgo/go/runtime/cgo_gccgo.go (working copy) @@ -54,7 +54,7 @@ func CgocallDone() { // If we are invoked because the C function called _cgo_panic, // then _cgo_panic will already have exited syscall mode. - if gp.atomicstatus == _Gsyscall { + if readgstatus(gp)&^_Gscan == _Gsyscall { exitsyscall(0) } Index: libgo/go/runtime/proc.go =================================================================== --- libgo/go/runtime/proc.go (revision 249125) +++ libgo/go/runtime/proc.go (working copy) @@ -1459,7 +1459,7 @@ func dropm() { // gccgo sets the stack to Gdead here, because the splitstack // context is not initialized. - mp.curg.atomicstatus = _Gdead + atomic.Store(&mp.curg.atomicstatus, _Gdead) mp.curg.gcstack = nil mp.curg.gcnextsp = nil