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: declaring non-callable append then attempting to call crashes gc #28211

Closed
Xjs opened this issue Oct 15, 2018 · 7 comments
Closed
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@Xjs
Copy link
Contributor

Xjs commented Oct 15, 2018

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

go version go1.11 windows/amd64 (also occurs under Linux or on the playground)

Does this issue reproduce with the latest release?

Yes

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

GOHOSTARCH=amd64
GOHOSTOS=windows

(also happens on playground)

What did you do?

MWE:

package main

func main() {
	var append bool
	append()
}

https://play.golang.org/p/Z36gAU5mgUY

What did you expect to see?

prog.go:5:9: cannot call non-function append (type bool)

What did you see instead?

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

goroutine 1 [running]:
cmd/compile/internal/gc.typecheck1(0xc00032c180, 0x1, 0xc00032c080)
	/usr/local/go/src/cmd/compile/internal/gc/typecheck.go:1270 +0x3ece
cmd/compile/internal/gc.typecheck(0xc00032c180, 0x1, 0xc00032c080)
	/usr/local/go/src/cmd/compile/internal/gc/typecheck.go:238 +0x6ad
cmd/compile/internal/gc.typecheckslice(0xc0003201c0, 0x3, 0x4, 0x1)
	/usr/local/go/src/cmd/compile/internal/gc/typecheck.go:68 +0x50
cmd/compile/internal/gc.Main(0xcc2180)
	/usr/local/go/src/cmd/compile/internal/gc/main.go:518 +0x2059
main.main()
	/usr/local/go/src/cmd/compile/main.go:51 +0x96

Spotted by @Weiss91

@agnivade
Copy link
Contributor

Fixed on tip. Also backported to 1.11.1

@Xjs
Copy link
Contributor Author

Xjs commented Oct 15, 2018

@agnivade Still occurs on play.golang.org (as of now, see
https://play.golang.org/p/Z36gAU5mgUY), 1.11.1/windows, 1.11.1/linux. So not sure about that backport.

@Xjs
Copy link
Contributor Author

Xjs commented Oct 15, 2018

Just checked with current master, still crashes. Please reopen.

PS C:\Users\jannis.schnitzer\src\stuff\panic-typecheck> cat .\main.go
package main

func main() {
        var append bool
        append()
}
PS C:\Users\jannis.schnitzer\src\stuff\panic-typecheck> C:\Users\jannis.schnitzer\src\go.googlesource.com\go\bin\go.exe build
# stuff/panic-typecheck
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x70 pc=0xb952c5]

goroutine 1 [running]:
cmd/compile/internal/gc.typecheck1(0xc000340200, 0x1, 0xc000340100)
        c:/go/src/cmd/compile/internal/gc/typecheck.go:1270 +0x3ed5
cmd/compile/internal/gc.typecheck(0xc000340200, 0x1, 0xc000340100)
        c:/go/src/cmd/compile/internal/gc/typecheck.go:238 +0x6b4
cmd/compile/internal/gc.typecheckslice(0xc00032a660, 0x3, 0x4, 0x1)
        c:/go/src/cmd/compile/internal/gc/typecheck.go:68 +0x57
cmd/compile/internal/gc.Main(0xcdfc60)
        c:/go/src/cmd/compile/internal/gc/main.go:518 +0x20d0
main.main()
        c:/go/src/cmd/compile/main.go:51 +0x9d
PS C:\Users\jannis.schnitzer\src\stuff\panic-typecheck> C:\Users\jannis.schnitzer\src\go.googlesource.com\go\bin\go.exe version
go version devel +93e27e01af Mon Oct 15 14:51:30 2018 +0000 windows/amd64
PS C:\Users\jannis.schnitzer\src\stuff\panic-typecheck>

@agnivade
Copy link
Contributor

I cannot reproduce. Possibly a windows issue ?

21:33:16-agniva-~/play/go/src$gotip run append.go 
# command-line-arguments
./append.go:5:9: cannot call non-function append (type bool)
21:35:35-agniva-~/play/go/src$gotip version
go version devel +296b7aeae0 Mon Oct 15 16:01:56 2018 +0000 linux/amd64
21:35:37-agniva-~/play/go/src$cat append.go 
package main

func main() {
  var append bool
  append()
}

@griesemer

@agnivade agnivade reopened this Oct 15, 2018
@agnivade agnivade added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker labels Oct 15, 2018
@agnivade agnivade added this to the Go1.12 milestone Oct 15, 2018
@griesemer
Copy link
Contributor

I cannot reproduce this either. Also, @Xjs I don't quite believe you're running current master: Your stack dump indicates a crash at c:/go/src/cmd/compile/internal/gc/typecheck.go:1270 which is the middle of a comment. Can you please update (and make sure you're using the newest compiler) and try again, thanks.

@griesemer griesemer added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker labels Oct 15, 2018
@Xjs
Copy link
Contributor Author

Xjs commented Oct 16, 2018

@griesemer Indeed, the go tool seems not to have called the freshly-built compile.exe. Can confirm that this error doesn't occur in tip on Windows anymore. Sorry for the confusion. (Can also confirm that 1.11.1's compile.exe does produce this error, though.)

@agnivade
Copy link
Contributor

Reason why it didn't get included for 1.11.1 - #27973 (comment).

Closing it now.

@golang golang locked and limited conversation to collaborators Oct 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants