Skip to content

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

@ldez

Description

@ldez

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:

Details
.
├── 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeToolsThis label describes issues relating to any tools in the x/tools repository.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions