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
Milestone

Comments

@dsnet
Copy link
Member

@dsnet 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 dsnet commented Jul 8, 2020

@gopherbot
Copy link

@gopherbot gopherbot commented Jul 8, 2020

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

@gopherbot gopherbot closed this in 0844ff8 Jul 8, 2020
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
2 participants
You can’t perform that action at this time.