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: compiler crashes on programs with 1<<30 array key #23780
Comments
I can reproduce the issue with |
The hang may be caused by my computer (8G memory) has not enough memory. If I change the slice element type to
|
You are trying to create a slice of 1073741824 integers. Which would mean you are trying to get 1073741824 * 8 bytes = 8GB of memory approximately. |
Yes. But I think the hang should occur at run time, instead of compile time. |
The second issue you reported (the fact that with
) looks more serious. I suspect it would do the same thing with |
I changed the issue's title to highlight the linker(?) crash you reported in your second post, since I believe it is more interesting that your machine getting slow on the program having the |
I think it is to do with the way the slice is being initialized. |
FTR: Note to the compiler guys: I guess the compiler tries to be nice wrt to initialization time and puts the images for composite literals in the text and/or data segments - triggering this issue. If that's the case I think the solution would be to detect when the composite literal is very sparse/mostly zero-values and perform instead a run time all-zero value creation and initialization of the non zero-valued items only all in code. |
@cznic Yes, the compiler could probably be a bit smarter here - on the other hand, perhaps one shouldn't write code like this. But I agree that the compiler shouldn't just appear to be hanging. To summarize:
|
Not urgent. Moving to 1.12. |
Related to #27447 |
Change https://golang.org/cl/151319 mentions this issue: |
What version of Go are you using (
go version
)?go version go1.9.3 linux/amd64
Does this issue reproduce with the latest release?
yes
What did you do?
a.go:
go build a.go
What did you expect to see?
produce a binary in one second.
What did you see instead?
computer becomes lagging, almost hanging.
I must press CTRL-C for several times to stop the building.
The text was updated successfully, but these errors were encountered: