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/crypto: fatal error: checkptr: unsafe pointer conversion #37715

Closed
karalabe opened this issue Mar 6, 2020 · 4 comments
Closed

x/crypto: fatal error: checkptr: unsafe pointer conversion #37715

karalabe opened this issue Mar 6, 2020 · 4 comments
Milestone

Comments

@karalabe
Copy link
Contributor

@karalabe karalabe commented Mar 6, 2020

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

$ go version
go version go1.14 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="/home/karalabe/.cache/go-build"
GOENV="/home/karalabe/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/work"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/google/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/google/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/work/src/github.com/ethereum/go-ethereum/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build817115371=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Create a racerepro package and dump this in:

package racerepro

import (
	"encoding/hex"
	"testing"

	"golang.org/x/crypto/sha3"
)

func TestRacePanic(t *testing.T) {
	b1, _ := hex.DecodeString("f90824")
	b2, _ := hex.DecodeString("b908000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000")

	hasher := sha3.NewLegacyKeccak256()
	hasher.Write(b1)
	hasher.Write(b2)
}

Run:

$ go test -race

What did you expect to see?

=== RUN   TestRacePanic
--- PASS: TestRacePanic (0.00s)
PASS

What did you see instead?

=== RUN   TestRacePanic
fatal error: checkptr: unsafe pointer conversion

goroutine 21 [running]:
runtime.throw(0x60923a, 0x23)
	/opt/google/go/src/runtime/panic.go:1112 +0x72 fp=0xc00003b530 sp=0xc00003b500 pc=0x45fcb2
runtime.checkptrAlignment(0xc0000de085, 0x5cae60, 0x11)
	/opt/google/go/src/runtime/checkptr.go:13 +0xd0 fp=0xc00003b560 sp=0xc00003b530 pc=0x433560
golang.org/x/crypto/sha3.xorInUnaligned(0xc0000e4000, 0xc0000de085, 0x88, 0x127b)
	/work/pkg/mod/golang.org/x/crypto@v0.0.0-20200302210943-78000ba7a073/sha3/xor_unaligned.go:21 +0x65 fp=0xc00003b5a0 sp=0xc00003b560 pc=0x5af875
golang.org/x/crypto/sha3.(*state).Write(0xc0000e4000, 0xc0000de085, 0x824, 0x127b, 0x3, 0x0, 0x0)
	/work/pkg/mod/golang.org/x/crypto@v0.0.0-20200302210943-78000ba7a073/sha3/sha3.go:138 +0x19e fp=0xc00003b640 sp=0xc00003b5a0 pc=0x5aeb6e
github.com/ethereum/go-ethereum/racerepro.TestRacePanic(0xc0000d6120)
	/work/src/github.com/ethereum/go-ethereum/racerepro/repro_test.go:16 +0x22a fp=0xc00003b6d0 sp=0xc00003b640 pc=0x5b535a
testing.tRunner(0xc0000d6120, 0x60d430)
	/opt/google/go/src/testing/testing.go:992 +0x1ec fp=0xc00003b7d0 sp=0xc00003b6d0 pc=0x54878c
runtime.goexit()
	/opt/google/go/src/runtime/asm_amd64.s:1373 +0x1 fp=0xc00003b7d8 sp=0xc00003b7d0 pc=0x491471
created by testing.(*T).Run
	/opt/google/go/src/testing/testing.go:1043 +0x661

Ref ethereum/go-ethereum#20731, discovery courtesy of @mvdan.

@gopherbot gopherbot added this to the Unreleased milestone Mar 6, 2020
@bcmills
Copy link
Member

@bcmills bcmills commented Mar 6, 2020

Duplicate of #37644

@bcmills bcmills marked this as a duplicate of #37644 Mar 6, 2020
@bcmills bcmills closed this Mar 6, 2020
@bcmills
Copy link
Member

@bcmills bcmills commented Mar 6, 2020

(In general, please search for existing issues before filing a new one. Sometimes GitHub search masks existing issues — and that's ok — but in this case the existing issue would not have been difficult to find.)

@karalabe
Copy link
Contributor Author

@karalabe karalabe commented Mar 6, 2020

Sorry. The original issue on our repo was opened a week ago, back then the linked dup didn't exist.

@gopherbot
Copy link

@gopherbot gopherbot commented Mar 11, 2020

Change https://golang.org/cl/222855 mentions this issue: sha3: mark xorInUnaligned with go:nocheckptr

gopherbot pushed a commit to golang/crypto that referenced this issue Mar 11, 2020
It is unclear whether unaligned reads should be allowed, or if they
are even actually a good idea here. However, while we figure that out,
we should un-break 'go test -race' for users of this package.

Updates golang/go#37644
Updates golang/go#37298
Updates golang/go#37715
Updates golang/go#34972
Updates golang/go#35128

Change-Id: I088f5703023e4f05ee274a6753e925973f12ac1b
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/222855
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.