Skip to content

unsafeptr analyzer of govet is not reporting errors #3820

Closed
@sherif-elmetainy

Description

@sherif-elmetainy

Welcome

  • Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc.).
  • Yes, I've tried with the standalone linter if available (e.g., gocritic, go vet, etc.). (https://golangci-lint.run/usage/linters/)

Description of the problem

The govet linter is not reporting errors by the unsafeptr analyzer.

When I run

$ go vet

I get

# playground
.\main.go:10:14: possible misuse of unsafe.Pointer

However when I run

$ golangci-lint run

I get nothing in the output.

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 1.52.2 built with go1.20.2 from da04413a on 2023-03-25T18:11:28Z

Configuration file

$ cat .golangci.yml
linters:
  disable-all: true
  enable:
    - govet
linters-settings:
  govet:
    check-shadowing: true
    enable-all: true

Go environment

$ go version && go env
go version go1.20.4 windows/amd64
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\sherif\AppData\Local\go-build
set GOENV=C:\Users\sherif\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\sherif\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\sherif\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.20.4
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
set GOMOD=C:\Users\sherif\source\repos\goplayground\go.mod
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\sherif\AppData\Local\Temp\go-build2838372069=/tmp/go-build -gno-record-gcc-switches

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
level=info msg="[config_reader] Config search paths: [./ C:\\Users\\sherif\\source\\repos\\goplayground C:\\Users\\sherif\\source\\repos C:\\Users\\sherif\\source C:\\Users\\sherif C:\\Users C:\\]"
level=info msg="[config_reader] Used config file .golangci.yml"
level=info msg="[lintersdb] Active 1 linters: [govet]"
level=info msg="[loader] Go packages loading at mode 575 (types_sizes|compiled_files|deps|exports_file|name|files|imports) took 464.0199ms"
level=info msg="[runner/filename_unadjuster] Pre-built 0 adjustments in 0s"
level=info msg="[linters_context/goanalysis] analyzers took 651.7682ms with top 10 stages: printf: 213.6807ms, ctrlflow: 213.2176ms, findcall: 196.5921ms, inspect: 23.2777ms, buildssa: 5.0001ms, loopclosure: 0s, testinggoroutine: 0s, copylocks: 0s, unusedresult: 0s, timeformat: 0s"
level=info msg="[runner] Issues before processing: 1, after processing: 0"
level=info msg="[runner] Processors filtering stat (out/in): cgo: 1/1, exclude-rules: 0/1, path_prettifier: 1/1, skip_files: 1/1, autogenerated_exclude: 1/1, filename_unadjuster: 1/1, skip_dirs: 1/1, identifier_marker: 1/1, exclude: 1/1"
level=info msg="[runner] processing took 526.6µs with stages: autogenerated_exclude: 526.6µs, max_from_linter: 0s, filename_unadjuster: 0s, skip_dirs: 0s, uniq_by_line: 0s, identifier_marker: 0s, path_shortener: 0s, path_prefixer: 0s, severity-rules: 0s, exclude: 0s, sort_results: 0s, max_per_file_from_linter: 0s, fixer: 0s, cgo: 0s, skip_files: 0s, diff: 0s, exclude-rules: 0s, source_code: 0s, nolint: 0s, path_prettifier: 0s, max_same_issues: 0s"
level=info msg="[runner] linters took 358.2113ms with stages: govet: 357.1565ms"
level=info msg="File cache stats: 0 entries of total size 0B"
level=info msg="Memory: 10 samples, avg is 64.1MB, max is 149.3MB"
level=info msg="Execution took 882.2994ms"

Code example or link to a public repository

package main

import (
	"fmt"
	"unsafe"
)

func main() {
	var x uintptr = 10000
	p := (*int)(unsafe.Pointer(x))
	fmt.Println(*p)
}

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions