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: os.Stdout.Write causes its argument to escape on Windows #57740

Open
ALTree opened this issue Jan 11, 2023 · 3 comments
Open

cmd/compile: os.Stdout.Write causes its argument to escape on Windows #57740

ALTree opened this issue Jan 11, 2023 · 3 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows Performance
Milestone

Comments

@ALTree
Copy link
Member

ALTree commented Jan 11, 2023

go version go1.19.5 linux/amd64
go version devel go1.20-76d39ae349 Tue Jan 10 20:34:22 2023 +0000 linux/amd64
package p

import "os"

func f() {
	os.Stdout.Write([]byte{'h', 'e', 'l', 'l', 'o'})
}

Linux:

$ GOOS=linux gotip build -gcflags=-m test.go

./test.go:5:6: can inline f
./test.go:6:24: []byte{...} does not escape             <<<<

Windows:

$ GOOS=windows gotip build -gcflags=-m test.go

./test.go:5:6: can inline f
./test.go:6:24: []byte{...} escapes to heap             <<<<

Read is also affected.

Reproducible on tip and 1.19.5.

Related to #41474

@ALTree ALTree added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jan 11, 2023
@ALTree ALTree added this to the Go1.21 milestone Jan 11, 2023
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jan 11, 2023
@cuonglm
Copy link
Member

cuonglm commented Jan 11, 2023

Isn't it still escaped on Windows: #41474 (comment)?

@ALTree
Copy link
Member Author

ALTree commented Jan 11, 2023

@cuonglm yep, but that issue of mine is from 2020 and closed, so I thought I'd open one to track the Windows issue at least. This problem prevents me from shipping a single codebase for an application that needs to run on Linux and Windows and not heap allocate.

@bcmills
Copy link
Member

bcmills commented Jan 11, 2023

CC @golang/windows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows Performance
Projects
None yet
Development

No branches or pull requests

4 participants