Skip to content

cmd/compile: tip crashes on too-large package-level array declarations #49814

Closed

Description

@zigo101

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

$ go version
go version devel go1.18-fad67f8a53 Sat Nov 27 01:14:21 2021 +0000 linux/amd64

Does this issue reproduce with the latest release?

Tip only.

What did you do?

package main

var X [1<<50]byte

func main() {}

What did you expect to see?

Not crash, just fails to compile.

What did you see instead?

Crash

Activity

  1. added
    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
    on Nov 27, 2021
  2. added this to the Go1.18 milestone on Nov 27, 2021
  3. ianlancetaylor commented on Nov 27, 2021

    @ianlancetaylor
    Contributor

    To clarify, it is the compiler that crashes, not the program.

    CC @griesemer @findleyr

    > go build foo.go
    # command-line-arguments
    <unknown line number>: internal compiler error: bad type: [1125899906842624]byte
    
    goroutine 1 [running]:
    runtime/debug.Stack()
    	/home/iant/go/src/runtime/debug/stack.go:24 +0x65
    cmd/compile/internal/base.FatalfAt({0x10?, 0x0?}, {0xd1d117, 0xc}, {0xc00057b380, 0x1, 0x1})
    	/home/iant/go/src/cmd/compile/internal/base/print.go:227 +0x1ca
    cmd/compile/internal/base.Fatalf(...)
    	/home/iant/go/src/cmd/compile/internal/base/print.go:196
    cmd/compile/internal/types.typePos(0xc0004278f0?)
    	/home/iant/go/src/cmd/compile/internal/types/size.go:53 +0xad
    cmd/compile/internal/types.CalcSize(0xc0000ac310)
    	/home/iant/go/src/cmd/compile/internal/types/size.go:495 +0x59e
    cmd/compile/internal/types.ResumeCheckSize()
    	/home/iant/go/src/cmd/compile/internal/types/size.go:628 +0x4e
    cmd/compile/internal/noder.(*irgen).typ(0xc0000b6000, {0xe8bba8?, 0xc000414090?})
    	/home/iant/go/src/cmd/compile/internal/noder/types.go:38 +0x3d
    cmd/compile/internal/noder.(*irgen).obj(0xc0000b6000, {0xe8ee30, 0xc000424240?})
    	/home/iant/go/src/cmd/compile/internal/noder/object.go:147 +0x965
    cmd/compile/internal/noder.(*irgen).def(0xc0000b6000, 0xc0000a6020)
    	/home/iant/go/src/cmd/compile/internal/noder/object.go:22 +0xbd
    cmd/compile/internal/noder.(*irgen).varDecl(0xc0000b6000, 0xc0001640f0, 0xc000424120)
    	/home/iant/go/src/cmd/compile/internal/noder/decl.go:243 +0xe5
    cmd/compile/internal/noder.(*irgen).decls(0xc0000b6000?, 0xc000596070?, {0xc0000a60a0?, 0x2, 0x203000?})
    	/home/iant/go/src/cmd/compile/internal/noder/decl.go:34 +0xfd
    cmd/compile/internal/noder.(*irgen).generate(0xc0000b6000, {0xc00006aa90, 0x2, 0x203000?})
    	/home/iant/go/src/cmd/compile/internal/noder/irgen.go:270 +0x1ed
    cmd/compile/internal/noder.check2({0xc00006aa90, 0x2, 0x2})
    	/home/iant/go/src/cmd/compile/internal/noder/irgen.go:92 +0x16d
    cmd/compile/internal/noder.LoadPackage({0xc00001e210, 0x2, 0x0?})
    	/home/iant/go/src/cmd/compile/internal/noder/noder.go:90 +0x335
    cmd/compile/internal/gc.Main(0xd496c0)
    	/home/iant/go/src/cmd/compile/internal/gc/main.go:191 +0xb13
    main.main()
    	/home/iant/go/src/cmd/compile/main.go:55 +0xdd
    
  4. griesemer commented on Nov 28, 2021

    @griesemer
    Contributor

    The crash happens while trying to report error "type %L larger than address space"; it appears that the type position is unknown.

  5. gopherbot commented on Nov 30, 2021

    @gopherbot
    Contributor

    Change https://golang.org/cl/367955 mentions this issue: cmd/compile: report channel size errors correctly for -G=3

  6. locked and limited conversation to collaborators on Jun 23, 2023
  7. added a commit that references this issue on Sep 19, 2024
    bbe1be5
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

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions