Skip to content

cmd/compile: seemingly non-deterministic object files on tip #82043

Closed

Description

@thepudds

This might be a recent regression.

I am still investigating and maybe there is something else going on, but wanted to file an initial issue while investigating.

Go version

$ go version
go version go1.28-devel_51bd6b1f32 Tue Oct 6 09:55:20 2026 -0700 linux/amd64

What did you see happen?

Originally seen while doing toolstash -cmp on a large CL stack, but reproduced on today's master.

Compiling the same file 100 times seems to yield different file on disk:

for x in $(seq 100); do
   go build -a -gcflags=-c=16 -o=repro-$x.a repro.go;
   sha256sum repro-$x.a | awk '{print $1}'; 
done | sort | uniq -c
     65 5a6b76d480aa9052b465273031ae97202041916c0713631ea370721cf0fa0661
     35 a1e6ea80381b543c509c008ab1f2f6d5443113d923628f79d9c623e72bf5b904

For this reproducer:

// simplification extracted from regexp/regexp.go.

package p

type Regexp struct{ n int }

//go:noinline
func (re *Regexp) find(dstCap []int) []int { return append(dstCap, 0, re.n) }

func (re *Regexp) Find(b []byte) []byte {
	var dstCap [2]int
	a := re.find(dstCap[:0])
	if a == nil {
		return nil
	}
	return b[a[0]:a[1]:a[1]]
}

func (re *Regexp) allIndex(m []int) func(yield func([]int) bool) {
	return func(yield func([]int) bool) {
		yield([]int{m[0], m[1]})
	}
}

Activity

  1. thepudds commented on Oct 6, 2026

    @thepudds
    MemberAuthor

    This non-determinism in the compiler seemed to bisect to 15bcf54:

    first BAD:   15bcf54708 | 2026-09-25 | cmd/compile, cmd/link: deduplicate alg and noalg type descriptors
    GOOD parent: dd60ba7ac2 | 2026-09-25 | simd: validation of test cleanup approach
    

    Maybe it is a race on which type is added first, or something along those lines?

    CC @cuonglm @golang/compiler

  2. thepudds commented on Oct 7, 2026

    @thepudds
    MemberAuthor

    Maybe it is a race on which type is added first

    Also, in basic testing, did not seem to reproduce with -gcflags=-c=1 but did reproduce with higher compiler concurrency.

  3. cuonglm commented on Oct 7, 2026

    @cuonglm
    Member

    @thepudds Thanks for bisecting.

    I think the issue is that typesStrCmp could not distinguish between alg and noalg anymore, causing the sorting becomes unstable.

    CL is coming!

  4. self-assigned this
    on Oct 7, 2026
  5. gopherbot commented on Oct 7, 2026

    @gopherbot
    Contributor

    Change https://go.dev/cl/846185 mentions this issue: cmd/compile: sort alg type before its noalg one

  6. added this to the Go1.28 milestone on Oct 7, 2026
  7. added
    FixPendingIssues that have a fix which has not yet been reviewed or submitted.
    on Oct 7, 2026
  8. added a commit that references this issue on Oct 7, 2026
    925ef8c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

FixPendingIssues that have a fix which has not yet been reviewed or submitted.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