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

runtime/cgo: cannot build with UndefinedBehaviorSanitizer #48121

Closed
elagergren-spideroak opened this issue Sep 1, 2021 · 5 comments
Closed
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@elagergren-spideroak
Copy link

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

$ go version
go version go1.17 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
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17"
GCCGO="gccgo"
AR="llvm-ar-12"
CC="clang-12"
CXX="clang++-12"
CGO_ENABLED="1"
GOMOD="/build/go.mod"
CGO_CFLAGS="-Wall -Wextra -Werror -fsanitize=undefined,address,integer -fno-sanitize-recover -Wno-unused-parameter"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-Wall -Wextra -Werror -fsanitize=undefined,address,integer -fno-sanitize-recover"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build802210746=/tmp/go-build -gno-record-gcc-switches"

What did you do?

https://play.golang.org/p/gs7sWBhKvCF

What did you expect to see?

It run successfully.

What did you see instead?

gcc_sigaction.c:55:33: runtime error: implicit conversion from type 'int' of value -67108865 (32-bit, signed) to type 'unsigned long' changed the value to 18446744073642442751 (64-bit, unsigned)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior gcc_sigaction.c:55:33 in
@elagergren-spideroak elagergren-spideroak changed the title cmd/compile: does not run with UndefinedBehaviorSanitizer runtime/cgo: does not run with UndefinedBehaviorSanitizer Sep 1, 2021
@elagergren-spideroak elagergren-spideroak changed the title runtime/cgo: does not run with UndefinedBehaviorSanitizer runtime/cgo: cannot build with UndefinedBehaviorSanitizer Sep 1, 2021
@randall77
Copy link
Contributor

Can you just add a uint64_t cast to SA_RESTORER (or at its use)?

@elagergren-spideroak
Copy link
Author

elagergren-spideroak commented Sep 1, 2021

@randall77 I can send a CL, sure.

FYI, this is from fe057c1.

@elagergren-spideroak
Copy link
Author

Ah, actually, we haven't signed the CLA yet. So, I don't think I'll be able to submit a CL in a timely manner.

@cherrymui cherrymui added the NeedsFix The path to resolution is known, but the work has not been done. label Sep 1, 2021
@cherrymui cherrymui added this to the Backlog milestone Sep 1, 2021
@cherrymui
Copy link
Member

cc @ianlancetaylor

@gopherbot
Copy link

Change https://golang.org/cl/348739 mentions this issue: cmd/cgo, runtime/cgo: avoid GCC/clang conversion warnings

@golang golang locked and limited conversation to collaborators Sep 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants