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

os: regression with nil handling and copy_file_range #40115

Closed
dsnet opened this issue Jul 8, 2020 · 2 comments
Closed

os: regression with nil handling and copy_file_range #40115

dsnet opened this issue Jul 8, 2020 · 2 comments

Comments

@dsnet
Copy link
Member

dsnet commented Jul 8, 2020

Consider the following snippet:

var src *os.File
dst, _ := os.Create("/tmp/file")
fmt.Println(io.Copy(dst, src))

On go1.14, this prints:

0 invalid argument

On go1.15, this panics with:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x490cc1]

goroutine 1 [running]:
os.(*File).readFrom(0xc000102018, 0x4dddc0, 0x0, 0x54da28, 0x1000000000000, 0x7f1f86dbcfe8, 0xc0000a0e70)
	os/readfrom_linux.go:36 +0x81
os.(*File).ReadFrom(0xc000102018, 0x4dddc0, 0x0, 0x7f1f86dbcfe8, 0xc000102018, 0x490301)
	os/file.go:151 +0x5c
io.copyBuffer(0x4ddde0, 0xc000102018, 0x4dddc0, 0x0, 0x0, 0x0, 0x0, 0xc000034778, 0xc0000a0f78, 0x405585)
	io/io.go:395 +0x2ff
io.Copy(...)
	io/io.go:368
main.main()
	main.go:15 +0x8c
@dsnet dsnet added this to the Go1.15 milestone Jul 8, 2020
@dsnet
Copy link
Member Author

dsnet commented Jul 8, 2020

\cc @ianlancetaylor @neild

@gopherbot
Copy link

Change https://golang.org/cl/241417 mentions this issue: os: fix regression with handling of nil *File

@golang golang locked and limited conversation to collaborators Jul 8, 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

2 participants