Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/go/analysis, syscall: ptrace redeclared in this block #44459

Closed
ldez opened this issue Feb 20, 2021 · 5 comments
Closed

x/tools/go/analysis, syscall: ptrace redeclared in this block #44459

ldez opened this issue Feb 20, 2021 · 5 comments
Labels
FrozenDueToAge Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@ldez
Copy link

ldez commented Feb 20, 2021

What version of Go are you using (go version)?

$ go version
go version go1.16 linux/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

What did you do?

Currently, I'm only able to reproduce inside my IDE (goland).

I'm still trying to reproduce outside of goland.

I'm thinking that the build tag is missing in syscall/ptrace_ios.go

I created a minimal reproducible (inside goland) project:

.
├── foo_test.go
├── go.mod
├── go.sum
└── testdata
    └── src
        └── a
            └── a.go

foo_test.go:

package sandbox

import (
	"testing"

	"golang.org/x/tools/go/analysis"
	"golang.org/x/tools/go/analysis/analysistest"
)

func TestBug(t *testing.T) {
	ana := &analysis.Analyzer{
		Name:     "ptrace-bug",
		Doc:      "example",
		Run: func(pass *analysis.Pass) (interface{}, error) {
			return nil, nil
		},
		Requires: nil,
	}

	testdata := analysistest.TestData()
	analysistest.Run(t, testdata, ana, "a")
}

a.go:

package a

import (
	"time"
)

func validCases() {
	_ = time.Second * 30
}

What did you expect to see?

GOROOT=/home/ldez/.gvm/gos/go1.16 #gosetup
GOPATH=/home/ldez/sources/go #gosetup
/home/ldez/.gvm/gos/go1.16/bin/go test -json ./...
=== RUN   TestBug
--- PASS: TestBug (0.52s)
PASS
ok  	github.com/golangci/sandbox	0.524s

Process finished with exit code 0

What did you see instead?

GOROOT=/home/ldez/.gvm/gos/go1.16 #gosetup
GOPATH=/home/ldez/sources/go #gosetup
/home/ldez/.gvm/gos/go1.16/bin/go test -json ./...
=== RUN   TestBug
/home/ldez/.gvm/gos/go1.16/src/syscall/zsyscall_linux_amd64.go:178:6: ptrace redeclared in this block
/home/ldez/.gvm/gos/go1.16/src/syscall/ptrace_ios.go:10:6: 	other declaration of ptrace
    analysistest.go:294: error analyzing ptrace-bug@a: analysis skipped due to errors in package
--- FAIL: TestBug (0.69s)

FAIL
FAIL	github.com/golangci/sandbox	0.694s

Process finished with exit code 1
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Feb 20, 2021
@gopherbot gopherbot added this to the Unreleased milestone Feb 20, 2021
@ldez
Copy link
Author

ldez commented Feb 20, 2021

I'm able to create a reproducible example without the IDE.

with go1.16:

$ go run .
-----------------
exit status 1
-----------------
/home/ldez/.gvm/gos/go1.16/src/syscall/zsyscall_linux_amd64.go:178:6: ptrace redeclared in this block
/home/ldez/.gvm/gos/go1.16/src/syscall/ptrace_ios.go:10:6:      other declaration of ptrace
--- FAIL: TestBug (0.78s)
    analysistest.go:294: error analyzing ptrace-bug@a: analysis skipped due to errors in package
FAIL
FAIL    github.com/golangci/sandbox     0.784s
FAIL

with go1.15:

 go run .
-----------------
<nil>
-----------------
ok      github.com/golangci/sandbox     0.436s

ptrace-bug-repo.zip

@gopherbot
Copy link

Change https://golang.org/cl/294634 mentions this issue: syscall: add explicit ios build tag

@ianlancetaylor
Copy link
Contributor

@gopherbot Please open backport to 1.16.

The 1.16 release can't be analyzed by tools built with earlier versions of Go, because those earlier releases don't recognize that "ios" is now a valid GOOS value. The fix is to use an explicit build tag. We should backport that fix to the 1.16 release branch.

@gopherbot
Copy link

Backport issue(s) opened: #44462 (for 1.16).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases.

@gopherbot
Copy link

Change https://golang.org/cl/294635 mentions this issue: [release-branch.go1.16] syscall: add explicit ios build tag

gopherbot pushed a commit that referenced this issue Feb 25, 2021
This permits analysis of the syscall package by tools built with
older versions of Go that do not recognize ios as a GOOS.

For #44459
Fixes #44462

Change-Id: I79cec2ffe0dbcbc2dc45a385e556dc9e62033125
Reviewed-on: https://go-review.googlesource.com/c/go/+/294634
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
(cherry picked from commit 03d36d8)
Reviewed-on: https://go-review.googlesource.com/c/go/+/294635
Reviewed-by: Cherry Zhang <cherryyz@google.com>
@golang golang locked and limited conversation to collaborators Feb 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants