Skip to content

cmd/compile: declaring non-callable append then attempting to call crashes gc #28211

Closed

Description

@Xjs

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

Activity

  1. agnivade commented on Oct 15, 2018

    @agnivade
    Contributor

    Fixed on tip. Also backported to 1.11.1

  2. Xjs commented on Oct 15, 2018

    @Xjs
    ContributorAuthor

    @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.

  3. Xjs commented on Oct 15, 2018

    @Xjs
    ContributorAuthor

    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>
    
  4. agnivade commented on Oct 15, 2018

    @agnivade
    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

  5. added
    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
    on Oct 15, 2018
  6. added this to the Go1.12 milestone on Oct 15, 2018
  7. griesemer commented on Oct 15, 2018

    @griesemer
    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.

  8. added
    WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.
    and removed
    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
    on Oct 15, 2018
  9. Xjs commented on Oct 16, 2018

    @Xjs
    ContributorAuthor

    @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.)

  10. agnivade commented on Oct 16, 2018

    @agnivade
    Contributor

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

    Closing it now.

  11. locked and limited conversation to collaborators on Oct 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeWaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions