Skip to content

cmd/compile: internal compiler error: MoveLoop too small #81240

Closed

Description

@YuanchengJiang

The following code:

package main
type large struct {
	large_d430158
	b [1500000000]byte
}
func (x large) f1() int {
	return 5
}
type large_d430158 struct {
	b [1500000000]byte
}

Resulted in this output:

# fflreduce
<autogenerated>:1: internal compiler error: '(*large).f1': MoveLoop too small:-1294967296, expect:24

goroutine 53 [running]:
runtime/debug.Stack()
	/home/fuzz/WorkSpace/fusion-fuzz/projects/go/go-src/src/runtime/debug/stack.go:26 +0x5e
cmd/compile/internal/base.FatalfAt({0x40e072d0?, 0xc8d?}, {0xc8d40e07270, 0x26}, {0xc8d3ffcfaa0, 0x3, 0x3})
	/home/fuzz/WorkSpace/fusion-fuzz/projects/go/go-src/src/cmd/compile/internal/base/print.go:232 +0x18b
cmd/compile/internal/base.Fatalf(...)
	/home/fuzz/WorkSpace/fusion-fuzz/projects/go/go-src/src/cmd/compile/internal/base/print.go:197
cmd/compile/internal/ssagen.(*ssafn).Fatalf(0x0?, {0x1ccfdc0?, 0x0?}, {0x106f596, 0x20}, {0xc8d3ffd46c0, 0x2, 0x8?})
	/home/fuzz/WorkSpace/fusion-fuzz/projects/go/go-src/src/cmd/compile/internal/ssagen/ssa.go:8056 +0x185
cmd/compile/internal/ssa.(*Func).FatalfWithPos(0xc8d3fd021c0, {0x19b4ae0?, 0x0?}, {0x106f596, 0x20}, {0xc8d3ffd46c0, 0x2, 0x2})
	/home/fuzz/WorkSpace/fusion-fuzz/projects/go/go-src/src/cmd/compile/internal/ssa/func.go:801 +0x190
cmd/compile/internal/ssa.(*Value).Fatalf(...)
	/home/fuzz/WorkSpace/fusion-fuzz/projects/go/go-src/src/cmd/compile/internal/ssa/value.go:559
cmd/compile/internal/riscv64.ssaGenValue(0xc8d3ffc6be0, 0xc8d40d14550)
	/home/fuzz/WorkSpace/fusion-fuzz/projects/go/go-src/src/cmd/compile/internal/riscv64/ssa.go:909 +0xe2f
cmd/compile/internal/ssagen.genssa({0x1a73ba8, 0x0}, 0xc8d3fd021c0, 0xc8d3ffc5ce0)
	/home/fuzz/WorkSpace/fusion-fuzz/projects/go/go-src/src/cmd/compile/internal/ssagen/ssa.go:7181 +0x19ac
cmd/compile/internal/ssagen.Compile({0x1a71270, 0x1d10160}, 0xc8d3fd72780, 0x2b, 0x0?)
	/home/fuzz/WorkSpace/fusion-fuzz/projects/go/go-src/src/cmd/compile/internal/ssagen/pgen.go:316 +0x513
cmd/compile/internal/gc.compileFunctions.func2()
	/home/fuzz/WorkSpace/fusion-fuzz/projects/go/go-src/src/cmd/compile/internal/gc/compile.go:174 +0x1b9
sync.(*WaitGroup).Go.func1()
	/home/fuzz/WorkSpace/fusion-fuzz/projects/go/go-src/src/sync/waitgroup.go:258 +0x4a
created by sync.(*WaitGroup).Go in goroutine 1
	/home/fuzz/WorkSpace/fusion-fuzz/projects/go/go-src/src/sync/waitgroup.go:238 +0x7d


To reproduce:

GOOS=linux GOARCH=riscv64 go build .

Compiler version:

go version go1.28-devel_603439a1 Fri Aug 28 21:44:26 2026 -0700 linux/amd64

Commit:

603439a1c6f2d37c7f02e246342847056ed04c21

Build configuration:

cd src && ./make.bash (GOROOT_BOOTSTRAP=go1.26.0)

Operating System:

Ubuntu 22.04 Host, Docker fusion-fuzz-go:latest

This bug was found by fusion-fuzz

Activity

  1. thepudds commented on Aug 31, 2026

    @thepudds
    Member

    On linux/amd64 (including on playground), this reports:

    ./prog.go:10:6: stack frame too large (>1GB): 0 MB locals + 2861 MB args
    

    A bisect treating the ICE as "BAD" and cross compiling for GOARCH=riscv64 seemed to land on 4dac9e0:

      first BAD:   4dac9e093f | 2025-09-10 02:42 | cmd/compile: use generated loops instead of DUFFCOPY on riscv64
      GOOD parent: 879ff736d3 | 2025-09-10 02:41 | cmd/compile: use generated loops instead of DUFFZERO on riscv64
    

    The "GOOD" parent commit reported stack frame too large (>1GB).

    CC @mengzhuo @golang/compiler

  2. mengzhuo commented on Aug 31, 2026

    @mengzhuo
    Contributor

    That's fun, I only changed riscv64 related part...

    OP shows underflow MoveLoop too small:-1294967296, expect:24 while stack frame too large

  3. added
    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
    on Aug 31, 2026
  4. randall77 commented on Aug 31, 2026

    @randall77
    Contributor

    Looks like this is a problem with packing a move size into 32 bits, here:

    (LoweredMoveLoop [ssa.MakeValAndOff(int32(s),int32(t.Alignment()))] dst src mem)

    We need to do this on riscv64 because we also need to record alignment. Probably we should put alignment in the Aux field instead, so we have a full 64 bits for the size.

  5. changed the title [-]ICE: MoveLoop too small[/-] [+]cmd/compile: internal compiler error: MoveLoop too small[/+] on Aug 31, 2026
  6. gopherbot commented on Aug 31, 2026

    @gopherbot
    Contributor

    Change https://go.dev/cl/824984 mentions this issue: cmd/compile: fix large riscv64 move/zero

  7. added a commit that references this issue on Sep 1, 2026
    5c1ad45
  8. randall77 commented on Sep 1, 2026

    @randall77
    Contributor

    @gopherbot Please open backport issues.

    This original report is not really strong motivation, as it is an ICE that is happening before we would otherwise report a "stack frame too big" error.
    But this could be more insidious. For large types (>2GB?), at certain sizes the compiler will silently incompletely zero or copy those types. Such types are probably really rare, but we should either compile them correctly, or barf somehow. Compiling them incorrectly is pretty bad.

  9. gopherbot commented on Sep 1, 2026

    @gopherbot
    Contributor

    Backport issue(s) opened: #81295 (for 1.26), #81296 (for 1.27).

    Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases.

  10. added this to the Go1.28 milestone on Sep 8, 2026
  11. added
    NeedsFixThe path to resolution is known, but the work has not been done.
    and removed
    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
    on Sep 8, 2026
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

    NeedsFixThe path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions