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

cmd/compile, runtime: go:nocheckptr not respected #42131

randall77 opened this issue Oct 21, 2020 · 2 comments

cmd/compile, runtime: go:nocheckptr not respected #42131

randall77 opened this issue Oct 21, 2020 · 2 comments


Copy link

@randall77 randall77 commented Oct 21, 2020

At tip, do

$ go test -gcflags=-d=checkptr net/http -run=WriteSetCookies
fatal error: checkptr: pointer arithmetic result points to invalid allocation

goroutine 6 [running]:
runtime.throw(0x1538101, 0x40)
	/Users/khr/sandbox/readonly/src/runtime/panic.go:1112 +0x72 fp=0xc0000604e8 sp=0xc0000604b8 pc=0x10395b2
runtime.checkptrArithmetic(0xc000060650, 0x0, 0x0, 0x0)
	/Users/khr/sandbox/readonly/src/runtime/checkptr.go:48 +0x1c8 fp=0xc000060520 sp=0xc0000604e8 pc=0x1009228
net/http.(*Cookie).String(0x18228a0, 0xc000182090, 0x1766660)
	/Users/khr/sandbox/readonly/src/net/http/cookie.go:179 +0xbb fp=0xc000060680 sp=0xc000060520 pc=0x12a989b
	/Users/khr/sandbox/readonly/src/net/http/cookie_test.go:158 +0xfc fp=0xc000060780 sp=0xc000060680 pc=0x130f95c
testing.tRunner(0xc000001e00, 0x1544960)
	/Users/khr/sandbox/readonly/src/testing/testing.go:1173 +0xef fp=0xc0000607d0 sp=0xc000060780 pc=0x110198f
	/Users/khr/sandbox/readonly/src/runtime/asm_amd64.s:1376 +0x1 fp=0xc0000607d8 sp=0xc0000607d0 pc=0x10722c1
created by testing.(*T).Run
	/Users/khr/sandbox/readonly/src/testing/testing.go:1218 +0x2b3

goroutine 1 [chan receive]:
testing.(*T).Run(0xc000001e00, 0x1519974, 0x13, 0x1544960, 0x1091b46)
	/Users/khr/sandbox/readonly/src/testing/testing.go:1219 +0x2da
	/Users/khr/sandbox/readonly/src/testing/testing.go:1491 +0x78
testing.tRunner(0xc000001c80, 0xc0000c9d60)
	/Users/khr/sandbox/readonly/src/testing/testing.go:1173 +0xef
testing.runTests(0xc00000e150, 0x1830600, 0x215, 0x215, 0xbfdc4b8416e9b130, 0x8bb2d7dbfe, 0x1835c40, 0xc0000c9e18)
	/Users/khr/sandbox/readonly/src/testing/testing.go:1489 +0x2fe
testing.(*M).Run(0xc000030080, 0x0)
	/Users/khr/sandbox/readonly/src/testing/testing.go:1397 +0x1eb
	/Users/khr/sandbox/readonly/src/net/http/main_test.go:23 +0x2b
	_testmain.go:1177 +0x165
FAIL	net/http	0.165s

It appears that even though strings.noescape is marked as go:nocheckptr, there is a checkptr invocation there.
Maybe related, it looks like strings.noescape got inlined, where it probably shouldn't have (because functions marked go:nocheckptr shouldn't be inlined? Not sure.)

runtime.checkptrArithmetic is passed a stack pointer with an empty set of originals, which is the proxmal cause of the assertion failure.


Copy link

@mdempsky mdempsky commented Oct 21, 2020

You need to use -gcflags=all=-d=checkptr. Selectively enabling -d=checkptr for just some packages (as -gcflags=-d=checkptr without all= does) isn't supported.

Copy link
Contributor Author

@randall77 randall77 commented Oct 21, 2020

Ah, ok. Thanks.

@randall77 randall77 closed this Oct 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

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