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

context: Breaking change in Go 1.15 not called out in the release notes #40737

Closed
dylan-bourque opened this issue Aug 12, 2020 · 3 comments
Closed

Comments

@dylan-bourque
Copy link

dylan-bourque commented Aug 12, 2020

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

$ go version
go version go1.15 linux/amd64

Does this issue reproduce with the latest release?

Yes. This is a new issue introduced in Go 1.15.

What operating system and processor architecture are you using (go env)?

go env Output (using the `golang:1.15` Docker image)
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
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"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/root/sandbox/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-build266629529=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Run pre-existing code that was passing nil as the parent context to context.WithValue(). Minimal example: https://play.golang.org/p/J0Bxux7Bfs6

What did you expect to see?

The string "didn't panic" written to standard out

What did you see instead?

panic: cannot create context from nil parent

goroutine 1 [running]:
context.WithValue(0x0, 0x0, 0x4afc80, 0xc0000961f0, 0x4afa40, 0x4e7ae0, 0x0, 0x0)
	/usr/local/go-faketime/src/context/context.go:521 +0x187
main.main()
	/tmp/sandbox506034916/prog.go:14 +0x77

Program exited: status 2.

This change in behavior was introduced by 0205790. While I agree with the change in principle, I feel like this should have been specifically called out in the release notes for Go 1.15.

Updating context.WithCancel(), context.WithDeadline() and context.WithValue() to panic when they did not in Go 1.14 and prior will likely be a breaking change for users and, I feel, should be a highlighted change for visibility.

@dylan-bourque dylan-bourque changed the title Breaking change in Go 1.15 not called out in the release notes context: Breaking change in Go 1.15 not called out in the release notes Aug 12, 2020
@icholy
Copy link

icholy commented Aug 12, 2020

It would be nice if passing a nil parent behaved the same as passing a context.Background()

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/248329 mentions this issue: doc/go1.15: include behavior updates to the context package

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/248331 mentions this issue: [release-branch.go1.15] doc/go1.15: include behavior updates to the context package

gopherbot pushed a commit that referenced this issue Aug 13, 2020
…ontext package

Fixes #40737

Change-Id: I8e2c1e1653d427af1ded6d61df1aa450e3c4d35c
Reviewed-on: https://go-review.googlesource.com/c/go/+/248329
Run-TryBot: Andrew Bonventre <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
(cherry picked from commit b235317)
Reviewed-on: https://go-review.googlesource.com/c/go/+/248331
Reviewed-by: Andrew Gerrand <[email protected]>
@golang golang locked and limited conversation to collaborators Aug 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants