Skip to content

cmd/compile: &(*input) causes segfault #71056

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

Closed
raphaelvigee opened this issue Dec 29, 2024 · 30 comments
Closed

cmd/compile: &(*input) causes segfault #71056

raphaelvigee opened this issue Dec 29, 2024 · 30 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime.

Comments

@raphaelvigee
Copy link

raphaelvigee commented Dec 29, 2024

Go version

go version go1.23.4 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/me/Library/Caches/go-build'
GOENV='/Users/me/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/me/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/me/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.23.4/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.23.4/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.23.4'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/me/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/Users/me/Documents/Code/project/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/p2/z4h94_g1745dxgtn7h72kjfr0000gn/T/go-build1265390623=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

package main

import (
	"slices"
	"sync"
)

type Child struct {
	Err error
	Something string
	Toy *Toy
	N int
}

type Toy struct {}

type Person struct {
	Children []Child
}

func clone(input *Person) *Person {
    // This variant causes the bug:
	//p := &(*input)
	//pp := p
    // This variant doesnt:
	p := *input
	pp := &p

	p.Children = slices.Clone(p.Children)

	for i, child := range p.Children {
		p.Children[i].Toy = &(*child.Toy)
	}

	return pp
}

func main() {
	p := &Person{Children: []Child{
		{N: 1, Toy: &Toy{}},
		{N: 2, Toy: &Toy{}},
		{N: 3, Toy: &Toy{}},
		{N: 4, Toy: &Toy{}},
		{N: 5, Toy: &Toy{}},
		{N: 6, Toy: &Toy{}},
	}}

	ch := make(chan struct{})

	var wg sync.WaitGroup
	for range 100000 {
		wg.Add(1)

		go func() {
			defer wg.Done()
			<-ch

			p := clone(p)

			p.Children = slices.DeleteFunc(p.Children, func(child Child) bool {
				return child.N %2 == 0
			})
		}()
	}

	close(ch)

	wg.Wait()
}

What did you see happen?

&(*input) caused segfault on p.Children[i].Toy = &(*child.Toy)

What did you expect to see?

*input and separate & doesnt

@raphaelvigee
Copy link
Author

I m wondering if i uncovered a compiler bug of if i'm missing something about pointers dereferencing

@raphaelvigee raphaelvigee changed the title import/path: issue title import/path: &(*input) causes segfault Dec 29, 2024
@raphaelvigee raphaelvigee changed the title import/path: &(*input) causes segfault &(*input) causes segfault Dec 29, 2024
@Jorropo
Copy link
Member

Jorropo commented Dec 29, 2024

I can't reproduce the crash.
The compiled output looks correct at first glance, p := &(*input) is a "no-op"* because * produce a value with the argument's pointer underlying addressability and & creates a pointer using the argument's value addressability.

*it is equivalent to if input == nil { panicNilDeref() } which is what it is compiled as


Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@Jorropo Jorropo closed this as not planned Won't fix, can't repro, duplicate, stale Dec 29, 2024
@raphaelvigee
Copy link
Author

I can reproduce it ~90% of the time (did you make sure to switch my sample code into "broken mode" ?)

I'm wondering, how is &(*input) different from this ?

p := *input
pp := &p

@ns-dkoblas
Copy link

Looking at the non-optimized output I see that there is a substantial different is what is done (e.g. the call to newobject). So I would make the assumption that in the reference to the underlying slice is being shared and thus being corrupted.

For the statement p := &(*input) -- failing case

  example.go:22		0x8b0a			f940bfe5		MOVD 376(RSP), R5	
  example.go:22		0x8b0e			398000bb		MOVB (R5), R27		
  example.go:22		0x8b12			f90053e5		MOVD R5, 160(RSP)	

While the program successfully runs when p := *input with the following assembly

  example.go:22		0x8ba5			90000000		ADRP 0(PC), R0		[0:8]R_ADDRARM64:type:main.Person	
  example.go:22		0x8ba9			91000000		ADD $0, R0, R0		
  example.go:22		0x8bad			94000000		CALL 0(PC)		[0:4]R_CALLARM64:runtime.newobject<1>	
  example.go:22		0x8bb1			f900b3e0		MOVD R0, 352(RSP)	
  example.go:22		0x8bb5			f940bfe1		MOVD 376(RSP), R1	
  example.go:22		0x8bb9			3980003b		MOVB (R1), R27		
  example.go:22		0x8bbd			f9400022		MOVD (R1), R2		
  example.go:22		0x8bc1			f9400423		MOVD 8(R1), R3		
  example.go:22		0x8bc5			f9400821		MOVD 16(R1), R1		
  example.go:22		0x8bc9			f9000403		MOVD R3, 8(R0)		
  example.go:22		0x8bcd			f9000801		MOVD R1, 16(R0)		
  example.go:22		0x8bd1			9000001b		ADRP 0(PC), R27		[0:8]R_ARM64_PCREL_LDST32:runtime.writeBarrier	
  example.go:22		0x8bd5			b9400361		MOVWU (R27), R1		
  example.go:22		0x8bd9			34000041		CBZW R1, 2(PC)		
  example.go:22		0x8bdd			14000002		JMP 2(PC)		
  example.go:22		0x8be1			14000006		JMP 6(PC)		
  example.go:22		0x8be5			94000000		CALL 0(PC)		[0:4]R_CALLARM64:runtime.gcWriteBarrier2	
  example.go:22		0x8be9			f9000322		MOVD R2, (R25)		
  example.go:22		0x8bed			f9400005		MOVD (R0), R5		
  example.go:22		0x8bf1			f9000725		MOVD R5, 8(R25)		
  example.go:22		0x8bf5			14000001		JMP 1(PC)		
  example.go:22		0x8bf9			f9000002		MOVD R2, (R0)		

@Jorropo
Copy link
Member

Jorropo commented Dec 29, 2024

I've tried running both, I'm on linux/amd64.v3 I've missed you are on arm64.
I'll post your test to the build cluster, looking at your tests even if your clone function doesn't do what you think it should do I don't see why it should panic either.

I'm wondering, how is &(*input) different from this ?

In go the * unary operator does not makes a copy, it creates a value using the underlying addressability of the pointer argument.
& also does not make a copy and it uses the underlying addressability of the value.
Among other things this makes & usable to grab pointers to fields or indexes even tho there is implicit pointer deref on [] and ..
Tl;Dr: * converts a pointer to a value without a copy, to make a copy you need to pass that value into anything else (a function, most operators like +, an := or =, ...)

@Jorropo Jorropo reopened this Dec 29, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/638856 mentions this issue: test: add test for 71056

@raphaelvigee
Copy link
Author

Thanks for your explanation.
So &(*var) is effectively a noop, i m wondering why so many cases seem to use that pattern ? Are there situations where it makes sense to do that ?

@Jorropo
Copy link
Member

Jorropo commented Dec 29, 2024

I am as puzzled as you are. It's not a no-op because it'll panic if passed a nil pointer but I doubt this is what all of the results in your codesearch intended.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/639195 mentions this issue: test: add test for 71056

@Jorropo
Copy link
Member

Jorropo commented Dec 29, 2024

Can you please try with go1.24.0-rc1 release ? CI succeeded when tested on today's master.

@Jorropo Jorropo changed the title &(*input) causes segfault cmd/compile: &(*input) causes segfault Dec 29, 2024
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Dec 29, 2024
@raphaelvigee
Copy link
Author

Right, so its not just me :) As long as I ve been doing go, this read to me as take this pointer, dereference it (which basically means that if I touch its members, other things that refer to that pointer wont see the change), and take a pointer of that new value
Pretty sure all the codesearch results thoughts the same...

Will test on 1.24 shortly
Where can i see the result of the CI on darwin/arm64 ?

@andig
Copy link
Contributor

andig commented Dec 29, 2024

fwiw I'm able to reproduce this on Mac M1 with 1.23.3, tip to follow in a second:

❯ gor test.go
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x1024cb424]

goroutine 11164 [running]:
main.clone(...)
	/Users/andig/htdocs/evcc/test.go:32
main.main.func1()
	/Users/andig/htdocs/evcc/test.go:58 +0x164
created by main.main in goroutine 1
	/Users/andig/htdocs/evcc/test.go:54 +0x118
exit status 2

With tip 2b794ed:

❯ gotip version
go version devel go1.24-2b794ed8 Fri Dec 27 17:23:24 2024 -0800 darwin/arm64
evcc master*​ ≡
❯ gotip run test.go
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x1025d7de0]

goroutine 38453 [running]:
main.clone(...)
	/Users/andig/htdocs/evcc/test.go:32
main.main.func1()
	/Users/andig/htdocs/evcc/test.go:58 +0x180
created by main.main in goroutine 1
	/Users/andig/htdocs/evcc/test.go:54 +0x118
exit status 2

@Jorropo
Copy link
Member

Jorropo commented Dec 29, 2024

@andig
Copy link
Contributor

andig commented Dec 29, 2024

@Jorropo can I somehow run tip's test suite locally after I've installed tip?

@Jorropo
Copy link
Member

Jorropo commented Dec 29, 2024

git fetch https://go.googlesource.com/go refs/changes/56/638856/2 && git checkout -b change-638856 FETCH_HEAD
cd src && ./all.bash

@raphaelvigee
Copy link
Author

I got it to happen once on linux/amd64 (on the first go run on go version go1.23.1 linux/amd64), but i havent been able to make it happen again

@raphaelvigee
Copy link
Author

@andig
Copy link
Contributor

andig commented Dec 29, 2024

Now that's a bit surprising:

`./all.bash` logs
Building Go cmd/dist using /opt/homebrew/Cellar/go/1.23.4/libexec. (go1.23.4 darwin/arm64)
Building Go toolchain1 using /opt/homebrew/Cellar/go/1.23.4/libexec.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for darwin/arm64.

##### Test execution environment.
# GOARCH: arm64
# CPU: Apple M1
# GOOS: darwin
# OS Version: Darwin 24.1.0 Darwin Kernel Version 24.1.0: Thu Oct 10 21:05:14 PDT 2024; root:xnu-11215.41.3~2/RELEASE_ARM64_T8103 arm64

##### Testing packages.
ok  	archive/tar	0.417s
ok  	archive/zip	0.516s
ok  	bufio	0.574s
ok  	bytes	0.441s
ok  	cmp	0.523s
ok  	compress/bzip2	0.853s
ok  	compress/flate	1.338s
ok  	compress/gzip	2.121s
ok  	compress/lzw	0.427s
ok  	compress/zlib	0.583s
ok  	container/heap	1.100s
ok  	container/list	0.921s
ok  	container/ring	0.748s
ok  	context	0.212s
ok  	crypto	3.074s
ok  	crypto/aes	0.494s
ok  	crypto/cipher	2.482s
ok  	crypto/des	0.459s
ok  	crypto/dsa	0.815s
ok  	crypto/ecdh	0.993s
ok  	crypto/ecdsa	0.397s
ok  	crypto/ed25519	0.540s
ok  	crypto/elliptic	0.321s
?   	crypto/fips140	[no test files]
ok  	crypto/hkdf	0.242s
ok  	crypto/hmac	0.180s
ok  	crypto/internal/boring	0.260s
?   	crypto/internal/boring/bbig	[no test files]
ok  	crypto/internal/boring/bcache	0.428s
?   	crypto/internal/boring/sig	[no test files]
?   	crypto/internal/cryptotest	[no test files]
?   	crypto/internal/entropy	[no test files]
?   	crypto/internal/fips140	[no test files]
ok  	crypto/internal/fips140/aes	0.207s
ok  	crypto/internal/fips140/aes/gcm	0.367s [no tests to run]
?   	crypto/internal/fips140/alias	[no test files]
ok  	crypto/internal/fips140/bigmod	0.598s
?   	crypto/internal/fips140/check	[no test files]
?   	crypto/internal/fips140/check/checktest	[no test files]
?   	crypto/internal/fips140/drbg	[no test files]
ok  	crypto/internal/fips140/ecdh	0.310s
ok  	crypto/internal/fips140/ecdsa	0.437s
?   	crypto/internal/fips140/ed25519	[no test files]
ok  	crypto/internal/fips140/edwards25519	0.631s
ok  	crypto/internal/fips140/edwards25519/field	0.692s
?   	crypto/internal/fips140/hkdf	[no test files]
?   	crypto/internal/fips140/hmac	[no test files]
ok  	crypto/internal/fips140/mlkem	0.632s
ok  	crypto/internal/fips140/nistec	0.668s [no tests to run]
ok  	crypto/internal/fips140/nistec/fiat	0.721s [no tests to run]
?   	crypto/internal/fips140/pbkdf2	[no test files]
ok  	crypto/internal/fips140/rsa	0.877s
?   	crypto/internal/fips140/sha256	[no test files]
?   	crypto/internal/fips140/sha3	[no test files]
?   	crypto/internal/fips140/sha512	[no test files]
?   	crypto/internal/fips140/ssh	[no test files]
?   	crypto/internal/fips140/subtle	[no test files]
?   	crypto/internal/fips140/tls12	[no test files]
?   	crypto/internal/fips140/tls13	[no test files]
ok  	crypto/internal/fips140deps	0.910s
?   	crypto/internal/fips140deps/byteorder	[no test files]
?   	crypto/internal/fips140deps/cpu	[no test files]
?   	crypto/internal/fips140deps/godebug	[no test files]
?   	crypto/internal/fips140only	[no test files]
ok  	crypto/internal/fips140test	1.060s
ok  	crypto/internal/hpke	0.476s
?   	crypto/internal/impl	[no test files]
?   	crypto/internal/randutil	[no test files]
ok  	crypto/internal/sysrand	0.397s
?   	crypto/internal/sysrand/internal/seccomp	[no test files]
ok  	crypto/md5	0.373s
ok  	crypto/mlkem	0.575s
ok  	crypto/pbkdf2	0.710s
ok  	crypto/rand	0.825s
ok  	crypto/rc4	0.631s
ok  	crypto/rsa	1.252s
ok  	crypto/sha1	0.595s
ok  	crypto/sha256	0.402s
ok  	crypto/sha3	1.703s
ok  	crypto/sha512	0.835s
ok  	crypto/subtle	0.564s
ok  	crypto/tls	5.582s
?   	crypto/tls/internal/fips140tls	[no test files]
ok  	crypto/x509	1.334s
?   	crypto/x509/internal/macos	[no test files]
?   	crypto/x509/pkix	[no test files]
ok  	database/sql	1.107s
ok  	database/sql/driver	0.799s
ok  	debug/buildinfo	0.568s
ok  	debug/dwarf	0.475s
ok  	debug/elf	0.624s
ok  	debug/gosym	0.382s
ok  	debug/macho	0.576s
ok  	debug/pe	0.633s
ok  	debug/plan9obj	0.718s
ok  	embed	0.716s [no tests to run]
ok  	embed/internal/embedtest	0.600s
?   	encoding	[no test files]
ok  	encoding/ascii85	0.759s
ok  	encoding/asn1	0.563s
ok  	encoding/base32	0.407s
ok  	encoding/base64	0.505s
ok  	encoding/binary	0.838s
ok  	encoding/csv	0.382s
ok  	encoding/gob	1.178s
ok  	encoding/hex	0.737s
ok  	encoding/json	0.563s
ok  	encoding/pem	1.015s
ok  	encoding/xml	0.750s
ok  	errors	0.201s
ok  	expvar	0.715s
ok  	flag	0.493s
ok  	fmt	0.605s
ok  	go/ast	0.339s
ok  	go/ast/internal/tests	0.358s
ok  	go/build	8.318s
ok  	go/build/constraint	0.664s
ok  	go/constant	0.806s
ok  	go/doc	1.821s
ok  	go/doc/comment	3.707s
ok  	go/format	0.816s
ok  	go/importer	1.450s
ok  	go/internal/gccgoimporter	0.698s
ok  	go/internal/gcimporter	5.268s
ok  	go/internal/srcimporter	22.855s
ok  	go/parser	0.755s
ok  	go/printer	0.474s
ok  	go/scanner	0.392s
ok  	go/token	0.766s
ok  	go/types	17.031s
ok  	go/version	0.548s
ok  	hash	0.383s
ok  	hash/adler32	0.731s
ok  	hash/crc32	0.599s
ok  	hash/crc64	0.215s
ok  	hash/fnv	0.289s
ok  	hash/maphash	0.582s
ok  	html	0.592s
ok  	html/template	0.865s
ok  	image	0.340s
ok  	image/color	0.390s
?   	image/color/palette	[no test files]
ok  	image/draw	0.865s
ok  	image/gif	0.410s
?   	image/internal/imageutil	[no test files]
ok  	image/jpeg	0.910s
ok  	image/png	0.382s
ok  	index/suffixarray	0.287s
ok  	internal/abi	0.563s
?   	internal/asan	[no test files]
?   	internal/bisect	[no test files]
ok  	internal/buildcfg	0.374s
?   	internal/bytealg	[no test files]
?   	internal/byteorder	[no test files]
?   	internal/cfg	[no test files]
ok  	internal/chacha8rand	0.217s
ok  	internal/copyright	3.471s
?   	internal/coverage	[no test files]
?   	internal/coverage/calloc	[no test files]
ok  	internal/coverage/cfile	3.021s
ok  	internal/coverage/cformat	0.293s
ok  	internal/coverage/cmerge	0.438s
?   	internal/coverage/decodecounter	[no test files]
?   	internal/coverage/decodemeta	[no test files]
?   	internal/coverage/encodecounter	[no test files]
?   	internal/coverage/encodemeta	[no test files]
ok  	internal/coverage/pods	0.405s
?   	internal/coverage/rtcov	[no test files]
ok  	internal/coverage/slicereader	0.249s
ok  	internal/coverage/slicewriter	0.180s
?   	internal/coverage/stringtab	[no test files]
ok  	internal/coverage/test	0.456s
?   	internal/coverage/uleb128	[no test files]
ok  	internal/cpu	0.295s
ok  	internal/dag	0.368s
ok  	internal/diff	0.588s
?   	internal/exportdata	[no test files]
?   	internal/filepathlite	[no test files]
ok  	internal/fmtsort	0.369s
ok  	internal/fuzz	0.194s
?   	internal/goarch	[no test files]
ok  	internal/godebug	2.415s
ok  	internal/godebugs	11.884s
?   	internal/goexperiment	[no test files]
?   	internal/goos	[no test files]
?   	internal/goroot	[no test files]
ok  	internal/gover	0.618s
?   	internal/goversion	[no test files]
ok  	internal/itoa	0.814s
?   	internal/lazyregexp	[no test files]
?   	internal/lazytemplate	[no test files]
?   	internal/msan	[no test files]
?   	internal/nettrace	[no test files]
?   	internal/obscuretestdata	[no test files]
?   	internal/oserror	[no test files]
ok  	internal/pkgbits	0.552s
ok  	internal/platform	2.627s
ok  	internal/poll	0.540s
ok  	internal/profile	0.421s
?   	internal/profilerecord	[no test files]
?   	internal/race	[no test files]
ok  	internal/reflectlite	0.496s
ok  	internal/runtime/atomic	0.445s
?   	internal/runtime/exithook	[no test files]
ok  	internal/runtime/maps	0.455s
ok  	internal/runtime/math	0.361s
ok  	internal/runtime/sys	0.534s
ok  	internal/saferio	0.948s
ok  	internal/singleflight	0.776s
?   	internal/stringslite	[no test files]
ok  	internal/sync	0.692s
ok  	internal/synctest	0.737s
?   	internal/syscall/execenv	[no test files]
?   	internal/syscall/unix	[no test files]
ok  	internal/sysinfo	0.413s
?   	internal/syslist	[no test files]
ok  	internal/testenv	0.873s
?   	internal/testlog	[no test files]
?   	internal/testpty	[no test files]
ok  	internal/trace	28.859s
?   	internal/trace/event	[no test files]
?   	internal/trace/event/go122	[no test files]
ok  	internal/trace/internal/oldtrace	0.405s
?   	internal/trace/internal/testgen/go122	[no test files]
?   	internal/trace/raw	[no test files]
?   	internal/trace/testtrace	[no test files]
?   	internal/trace/traceviewer	[no test files]
?   	internal/trace/traceviewer/format	[no test files]
?   	internal/trace/version	[no test files]
?   	internal/txtar	[no test files]
ok  	internal/types/errors	3.063s
ok  	internal/unsafeheader	0.380s
ok  	internal/xcoff	0.574s
ok  	internal/zstd	0.709s
ok  	io	0.754s
ok  	io/fs	0.746s
ok  	io/ioutil	0.603s
ok  	iter	0.746s
ok  	log	0.741s
?   	log/internal	[no test files]
ok  	log/slog	0.641s
?   	log/slog/internal	[no test files]
ok  	log/slog/internal/benchmarks	0.419s
ok  	log/slog/internal/buffer	0.560s
?   	log/slog/internal/slogtest	[no test files]
ok  	log/syslog	1.731s
ok  	maps	0.584s
ok  	math	0.491s
ok  	math/big	1.375s
ok  	math/bits	0.210s
ok  	math/cmplx	0.371s
ok  	math/rand	1.290s
ok  	math/rand/v2	1.741s
ok  	mime	0.746s
ok  	mime/multipart	2.102s
ok  	mime/quotedprintable	1.336s
ok  	net	3.180s
ok  	net/http	7.085s
ok  	net/http/cgi	0.570s
ok  	net/http/cookiejar	0.835s
ok  	net/http/fcgi	0.842s
ok  	net/http/httptest	1.081s
ok  	net/http/httptrace	0.753s
ok  	net/http/httputil	2.032s
ok  	net/http/internal	0.309s
ok  	net/http/internal/ascii	0.450s
?   	net/http/internal/testcert	[no test files]
ok  	net/http/pprof	5.075s
ok  	net/internal/cgotest	0.427s
ok  	net/internal/socktest	0.251s
ok  	net/mail	0.597s
ok  	net/netip	0.916s
ok  	net/rpc	0.490s
ok  	net/rpc/jsonrpc	1.094s
ok  	net/smtp	0.525s
ok  	net/textproto	0.705s
ok  	net/url	0.743s
ok  	os	7.028s
ok  	os/exec	1.157s
ok  	os/exec/internal/fdtest	1.097s
ok  	os/signal	3.425s
ok  	os/user	0.578s
ok  	path	0.907s
ok  	path/filepath	0.452s
ok  	plugin	0.747s
ok  	reflect	1.181s
?   	reflect/internal/example1	[no test files]
?   	reflect/internal/example2	[no test files]
ok  	regexp	1.029s
ok  	regexp/syntax	1.302s
ok  	runtime	57.305s
ok  	runtime/cgo	0.507s
?   	runtime/coverage	[no test files]
ok  	runtime/debug	0.835s
ok  	runtime/internal/wasitest	1.189s
ok  	runtime/metrics	0.998s
ok  	runtime/pprof	32.784s
?   	runtime/race	[no test files]
ok  	runtime/trace	1.149s
ok  	slices	1.017s
ok  	sort	0.525s
ok  	strconv	0.812s
ok  	strings	0.712s
?   	structs	[no test files]
ok  	sync	1.471s
ok  	sync/atomic	0.723s
ok  	syscall	1.324s
ok  	testing	2.560s
ok  	testing/fstest	0.557s
?   	testing/internal/testdeps	[no test files]
ok  	testing/iotest	0.358s
ok  	testing/quick	0.712s
ok  	testing/slogtest	0.754s
ok  	text/scanner	0.728s
ok  	text/tabwriter	0.846s
ok  	text/template	0.893s
ok  	text/template/parse	0.400s
ok  	time	6.752s
?   	time/tzdata	[no test files]
ok  	unicode	0.409s
ok  	unicode/utf16	0.562s
ok  	unicode/utf8	0.717s
ok  	unique	0.767s
?   	unsafe	[no test files]
ok  	weak	0.409s
ok  	cmd/addr2line	3.969s
ok  	cmd/api	151.005s
?   	cmd/asm	[no test files]
?   	cmd/asm/internal/arch	[no test files]
ok  	cmd/asm/internal/asm	0.788s
?   	cmd/asm/internal/flags	[no test files]
ok  	cmd/asm/internal/lex	0.431s
?   	cmd/buildid	[no test files]
?   	cmd/cgo	[no test files]
?   	cmd/cgo/internal/cgotest	[no test files]
ok  	cmd/cgo/internal/swig	0.499s
ok  	cmd/cgo/internal/test	0.355s
?   	cmd/cgo/internal/test/gcc68255	[no test files]
?   	cmd/cgo/internal/test/issue23555a	[no test files]
?   	cmd/cgo/internal/test/issue23555b	[no test files]
?   	cmd/cgo/internal/test/issue24161arg	[no test files]
?   	cmd/cgo/internal/test/issue24161e0	[no test files]
?   	cmd/cgo/internal/test/issue24161e1	[no test files]
?   	cmd/cgo/internal/test/issue24161e2	[no test files]
?   	cmd/cgo/internal/test/issue24161res	[no test files]
?   	cmd/cgo/internal/test/issue26213	[no test files]
?   	cmd/cgo/internal/test/issue26430	[no test files]
?   	cmd/cgo/internal/test/issue26743	[no test files]
?   	cmd/cgo/internal/test/issue27054	[no test files]
?   	cmd/cgo/internal/test/issue27340	[no test files]
?   	cmd/cgo/internal/test/issue29563	[no test files]
?   	cmd/cgo/internal/test/issue30527	[no test files]
?   	cmd/cgo/internal/test/issue41761a	[no test files]
?   	cmd/cgo/internal/test/issue43639	[no test files]
?   	cmd/cgo/internal/test/issue52611a	[no test files]
?   	cmd/cgo/internal/test/issue52611b	[no test files]
?   	cmd/cgo/internal/test/issue8756	[no test files]
?   	cmd/cgo/internal/test/issue8828	[no test files]
?   	cmd/cgo/internal/test/issue9026	[no test files]
?   	cmd/cgo/internal/test/issue9510a	[no test files]
?   	cmd/cgo/internal/test/issue9510b	[no test files]
ok  	cmd/cgo/internal/testcarchive	0.321s
ok  	cmd/cgo/internal/testcshared	0.357s
ok  	cmd/cgo/internal/testerrors	32.298s
ok  	cmd/cgo/internal/testfortran	0.721s
ok  	cmd/cgo/internal/testgodefs	4.800s
ok  	cmd/cgo/internal/testlife	3.882s
ok  	cmd/cgo/internal/testnocgo	0.572s
ok  	cmd/cgo/internal/testplugin	0.595s
ok  	cmd/cgo/internal/testsanitizers	0.239s [no tests to run]
ok  	cmd/cgo/internal/testshared	0.383s
ok  	cmd/cgo/internal/testso	9.248s
ok  	cmd/cgo/internal/teststdio	9.855s
ok  	cmd/cgo/internal/testtls	0.482s
ok  	cmd/compile	8.666s
?   	cmd/compile/internal/abi	[no test files]
ok  	cmd/compile/internal/abt	0.497s
ok  	cmd/compile/internal/amd64	0.377s
?   	cmd/compile/internal/arm	[no test files]
?   	cmd/compile/internal/arm64	[no test files]
ok  	cmd/compile/internal/base	0.436s
?   	cmd/compile/internal/bitvec	[no test files]
ok  	cmd/compile/internal/compare	0.949s
?   	cmd/compile/internal/coverage	[no test files]
?   	cmd/compile/internal/deadlocals	[no test files]
ok  	cmd/compile/internal/devirtualize	1.048s
ok  	cmd/compile/internal/dwarfgen	1.622s
?   	cmd/compile/internal/escape	[no test files]
?   	cmd/compile/internal/gc	[no test files]
ok  	cmd/compile/internal/importer	7.745s
?   	cmd/compile/internal/inline	[no test files]
ok  	cmd/compile/internal/inline/inlheur	4.502s
?   	cmd/compile/internal/inline/interleaved	[no test files]
ok  	cmd/compile/internal/ir	1.738s
ok  	cmd/compile/internal/liveness	0.745s
ok  	cmd/compile/internal/logopt	0.621s
?   	cmd/compile/internal/loong64	[no test files]
ok  	cmd/compile/internal/loopvar	85.980s
?   	cmd/compile/internal/mips	[no test files]
?   	cmd/compile/internal/mips64	[no test files]
ok  	cmd/compile/internal/noder	0.623s
?   	cmd/compile/internal/objw	[no test files]
?   	cmd/compile/internal/pgoir	[no test files]
?   	cmd/compile/internal/pkginit	[no test files]
?   	cmd/compile/internal/ppc64	[no test files]
ok  	cmd/compile/internal/rangefunc	0.707s
ok  	cmd/compile/internal/reflectdata	0.906s [no tests to run]
?   	cmd/compile/internal/riscv64	[no test files]
?   	cmd/compile/internal/rttype	[no test files]
?   	cmd/compile/internal/s390x	[no test files]
ok  	cmd/compile/internal/ssa	37.456s
ok  	cmd/compile/internal/ssagen	0.696s
?   	cmd/compile/internal/staticdata	[no test files]
?   	cmd/compile/internal/staticinit	[no test files]
ok  	cmd/compile/internal/syntax	1.906s
ok  	cmd/compile/internal/test	22.005s
?   	cmd/compile/internal/typebits	[no test files]
ok  	cmd/compile/internal/typecheck	2.409s
ok  	cmd/compile/internal/types	0.634s
ok  	cmd/compile/internal/types2	29.011s
?   	cmd/compile/internal/walk	[no test files]
?   	cmd/compile/internal/wasm	[no test files]
?   	cmd/compile/internal/x86	[no test files]
ok  	cmd/covdata	0.917s
ok  	cmd/cover	12.995s
ok  	cmd/dist	0.662s
ok  	cmd/distpack	0.243s
ok  	cmd/doc	2.651s
ok  	cmd/fix	11.291s
ok  	cmd/go	147.406s
ok  	cmd/go/internal/auth	0.466s
?   	cmd/go/internal/base	[no test files]
?   	cmd/go/internal/bug	[no test files]
ok  	cmd/go/internal/cache	6.823s
ok  	cmd/go/internal/cfg	0.368s [no tests to run]
?   	cmd/go/internal/clean	[no test files]
?   	cmd/go/internal/cmdflag	[no test files]
?   	cmd/go/internal/doc	[no test files]
ok  	cmd/go/internal/envcmd	0.357s
ok  	cmd/go/internal/fips140	1.042s
?   	cmd/go/internal/fix	[no test files]
?   	cmd/go/internal/fmtcmd	[no test files]
ok  	cmd/go/internal/fsys	2.785s
ok  	cmd/go/internal/generate	0.280s
ok  	cmd/go/internal/gover	0.588s
?   	cmd/go/internal/help	[no test files]
ok  	cmd/go/internal/imports	1.383s
?   	cmd/go/internal/list	[no test files]
ok  	cmd/go/internal/load	1.035s
ok  	cmd/go/internal/lockedfile	1.328s
ok  	cmd/go/internal/lockedfile/internal/filelock	0.553s
?   	cmd/go/internal/mmap	[no test files]
?   	cmd/go/internal/modcmd	[no test files]
ok  	cmd/go/internal/modfetch	0.445s
ok  	cmd/go/internal/modfetch/codehost	18.560s
ok  	cmd/go/internal/modfetch/zip_sum_test	0.257s
?   	cmd/go/internal/modget	[no test files]
ok  	cmd/go/internal/modindex	5.013s
?   	cmd/go/internal/modinfo	[no test files]
ok  	cmd/go/internal/modload	0.559s
ok  	cmd/go/internal/mvs	0.237s
?   	cmd/go/internal/run	[no test files]
?   	cmd/go/internal/search	[no test files]
ok  	cmd/go/internal/str	0.204s
?   	cmd/go/internal/telemetrycmd	[no test files]
?   	cmd/go/internal/telemetrystats	[no test files]
ok  	cmd/go/internal/test	0.350s
?   	cmd/go/internal/test/internal/genflags	[no test files]
?   	cmd/go/internal/tool	[no test files]
ok  	cmd/go/internal/toolchain	1.333s
?   	cmd/go/internal/trace	[no test files]
ok  	cmd/go/internal/vcs	1.108s
ok  	cmd/go/internal/vcweb	2.611s
ok  	cmd/go/internal/vcweb/vcstest	19.067s
?   	cmd/go/internal/version	[no test files]
?   	cmd/go/internal/vet	[no test files]
ok  	cmd/go/internal/web	1.019s
?   	cmd/go/internal/web/intercept	[no test files]
ok  	cmd/go/internal/work	1.011s
?   	cmd/go/internal/workcmd	[no test files]
ok  	cmd/gofmt	1.741s
ok  	cmd/internal/archive	12.193s
?   	cmd/internal/bio	[no test files]
ok  	cmd/internal/bootstrap_test	0.228s
?   	cmd/internal/browser	[no test files]
ok  	cmd/internal/buildid	1.548s
?   	cmd/internal/codesign	[no test files]
ok  	cmd/internal/cov	5.696s
?   	cmd/internal/cov/covcmd	[no test files]
?   	cmd/internal/disasm	[no test files]
ok  	cmd/internal/dwarf	1.393s
ok  	cmd/internal/edit	0.204s
?   	cmd/internal/gcprog	[no test files]
ok  	cmd/internal/goobj	1.381s
?   	cmd/internal/hash	[no test files]
?   	cmd/internal/macho	[no test files]
ok  	cmd/internal/moddeps	16.914s
ok  	cmd/internal/obj	1.904s
?   	cmd/internal/obj/arm	[no test files]
ok  	cmd/internal/obj/arm64	0.495s
ok  	cmd/internal/obj/loong64	0.672s
?   	cmd/internal/obj/mips	[no test files]
ok  	cmd/internal/obj/ppc64	1.371s
ok  	cmd/internal/obj/riscv	0.690s
ok  	cmd/internal/obj/s390x	0.422s
?   	cmd/internal/obj/wasm	[no test files]
ok  	cmd/internal/obj/x86	5.778s
ok  	cmd/internal/objabi	0.217s
?   	cmd/internal/objfile	[no test files]
ok  	cmd/internal/osinfo	0.235s
ok  	cmd/internal/par	1.158s
?   	cmd/internal/pathcache	[no test files]
ok  	cmd/internal/pgo	0.801s
ok  	cmd/internal/pkgpath	0.681s
ok  	cmd/internal/pkgpattern	0.637s
ok  	cmd/internal/quoted	0.802s
?   	cmd/internal/robustio	[no test files]
?   	cmd/internal/script	[no test files]
?   	cmd/internal/script/scripttest	[no test files]
ok  	cmd/internal/src	0.217s
ok  	cmd/internal/sys	0.814s
?   	cmd/internal/telemetry	[no test files]
?   	cmd/internal/telemetry/counter	[no test files]
ok  	cmd/internal/test2json	0.375s
ok  	cmd/link	53.101s
?   	cmd/link/internal/amd64	[no test files]
?   	cmd/link/internal/arm	[no test files]
?   	cmd/link/internal/arm64	[no test files]
ok  	cmd/link/internal/benchmark	0.292s
?   	cmd/link/internal/dwtest	[no test files]
ok  	cmd/link/internal/ld	54.171s
?   	cmd/link/internal/loadelf	[no test files]
ok  	cmd/link/internal/loader	0.447s
?   	cmd/link/internal/loadmacho	[no test files]
?   	cmd/link/internal/loadpe	[no test files]
?   	cmd/link/internal/loadxcoff	[no test files]
?   	cmd/link/internal/loong64	[no test files]
?   	cmd/link/internal/mips	[no test files]
?   	cmd/link/internal/mips64	[no test files]
?   	cmd/link/internal/ppc64	[no test files]
?   	cmd/link/internal/riscv64	[no test files]
?   	cmd/link/internal/s390x	[no test files]
?   	cmd/link/internal/sym	[no test files]
?   	cmd/link/internal/wasm	[no test files]
?   	cmd/link/internal/x86	[no test files]
ok  	cmd/nm	10.078s
ok  	cmd/objdump	16.724s
ok  	cmd/pack	9.111s
ok  	cmd/pprof	3.634s
?   	cmd/preprofile	[no test files]
ok  	cmd/relnote	0.912s
?   	cmd/test2json	[no test files]
ok  	cmd/trace	0.817s
ok  	cmd/vet	22.473s

##### os/user with tag osusergo
ok  	os/user	1.406s

##### hash/maphash purego implementation
ok  	hash/maphash	1.023s

##### crypto with tag purego (build and vet only)
?   	crypto/fips140	[no test files]
?   	crypto/internal/boring/bbig	[no test files]
?   	crypto/internal/boring/sig	[no test files]
?   	crypto/internal/cryptotest	[no test files]
?   	crypto/internal/entropy	[no test files]
?   	crypto/internal/fips140	[no test files]
?   	crypto/internal/fips140/alias	[no test files]
?   	crypto/internal/fips140/check	[no test files]
?   	crypto/internal/fips140/check/checktest	[no test files]
?   	crypto/internal/fips140/drbg	[no test files]
?   	crypto/internal/fips140/ed25519	[no test files]
?   	crypto/internal/fips140/hkdf	[no test files]
?   	crypto/internal/fips140/hmac	[no test files]
?   	crypto/internal/fips140/pbkdf2	[no test files]
?   	crypto/internal/fips140/sha256	[no test files]
?   	crypto/internal/fips140/sha3	[no test files]
?   	crypto/internal/fips140/sha512	[no test files]
?   	crypto/internal/fips140/ssh	[no test files]
?   	crypto/internal/fips140/subtle	[no test files]
?   	crypto/internal/fips140/tls12	[no test files]
?   	crypto/internal/fips140/tls13	[no test files]
?   	crypto/internal/fips140deps/byteorder	[no test files]
?   	crypto/internal/fips140deps/cpu	[no test files]
?   	crypto/internal/fips140deps/godebug	[no test files]
?   	crypto/internal/fips140only	[no test files]
?   	crypto/internal/impl	[no test files]
?   	crypto/internal/randutil	[no test files]
?   	crypto/internal/sysrand/internal/seccomp	[no test files]
?   	crypto/tls/internal/fips140tls	[no test files]
?   	crypto/x509/internal/macos	[no test files]
?   	crypto/x509/pkix	[no test files]

##### GODEBUG=fips140=on go test crypto/...
ok  	crypto	8.733s
ok  	crypto/aes	0.263s
ok  	crypto/cipher	2.176s
ok  	crypto/des	0.716s
ok  	crypto/dsa	0.524s
ok  	crypto/ecdh	0.237s
ok  	crypto/ecdsa	0.268s
ok  	crypto/ed25519	0.529s
ok  	crypto/elliptic	0.232s
?   	crypto/fips140	[no test files]
ok  	crypto/hkdf	0.801s
ok  	crypto/hmac	0.376s
ok  	crypto/internal/boring	1.043s
?   	crypto/internal/boring/bbig	[no test files]
ok  	crypto/internal/boring/bcache	0.529s
?   	crypto/internal/boring/sig	[no test files]
?   	crypto/internal/cryptotest	[no test files]
?   	crypto/internal/entropy	[no test files]
?   	crypto/internal/fips140	[no test files]
ok  	crypto/internal/fips140/aes	0.770s
ok  	crypto/internal/fips140/aes/gcm	0.233s [no tests to run]
?   	crypto/internal/fips140/alias	[no test files]
ok  	crypto/internal/fips140/bigmod	1.121s
?   	crypto/internal/fips140/check	[no test files]
?   	crypto/internal/fips140/check/checktest	[no test files]
?   	crypto/internal/fips140/drbg	[no test files]
ok  	crypto/internal/fips140/ecdh	0.668s
ok  	crypto/internal/fips140/ecdsa	0.469s
?   	crypto/internal/fips140/ed25519	[no test files]
ok  	crypto/internal/fips140/edwards25519	0.815s
ok  	crypto/internal/fips140/edwards25519/field	0.623s
?   	crypto/internal/fips140/hkdf	[no test files]
?   	crypto/internal/fips140/hmac	[no test files]
ok  	crypto/internal/fips140/mlkem	0.828s
ok  	crypto/internal/fips140/nistec	0.932s [no tests to run]
ok  	crypto/internal/fips140/nistec/fiat	0.881s [no tests to run]
?   	crypto/internal/fips140/pbkdf2	[no test files]
ok  	crypto/internal/fips140/rsa	0.402s
?   	crypto/internal/fips140/sha256	[no test files]
?   	crypto/internal/fips140/sha3	[no test files]
?   	crypto/internal/fips140/sha512	[no test files]
?   	crypto/internal/fips140/ssh	[no test files]
?   	crypto/internal/fips140/subtle	[no test files]
?   	crypto/internal/fips140/tls12	[no test files]
?   	crypto/internal/fips140/tls13	[no test files]
ok  	crypto/internal/fips140deps	1.362s
?   	crypto/internal/fips140deps/byteorder	[no test files]
?   	crypto/internal/fips140deps/cpu	[no test files]
?   	crypto/internal/fips140deps/godebug	[no test files]
?   	crypto/internal/fips140only	[no test files]
ok  	crypto/internal/fips140test	3.424s
ok  	crypto/internal/hpke	1.262s
?   	crypto/internal/impl	[no test files]
?   	crypto/internal/randutil	[no test files]
ok  	crypto/internal/sysrand	0.688s
?   	crypto/internal/sysrand/internal/seccomp	[no test files]
ok  	crypto/md5	0.967s
ok  	crypto/mlkem	1.033s
ok  	crypto/pbkdf2	0.653s
ok  	crypto/rand	0.680s
ok  	crypto/rc4	0.694s
ok  	crypto/rsa	1.791s
ok  	crypto/sha1	0.387s
ok  	crypto/sha256	1.319s
ok  	crypto/sha3	1.293s
ok  	crypto/sha512	1.572s
ok  	crypto/subtle	0.455s
ok  	crypto/tls	3.790s
?   	crypto/tls/internal/fips140tls	[no test files]
ok  	crypto/x509	1.037s
?   	crypto/x509/internal/macos	[no test files]
?   	crypto/x509/pkix	[no test files]

##### Testing without libgcc.
ok  	net	0.961s
ok  	os/user	1.039s

##### internal linking, -buildmode=pie
ok  	reflect	1.076s
ok  	crypto/internal/fips140test	0.891s
ok  	os/user	0.542s

##### external linking, -buildmode=exe
ok  	crypto/internal/fips140test	0.738s

##### external linking, -buildmode=pie
ok  	crypto/internal/fips140test	0.356s

##### sync -cpu=10
ok  	sync	1.017s

##### Testing cgo
ok  	cmd/cgo/internal/test	0.370s
ok  	cmd/cgo/internal/test	0.846s
ok  	cmd/cgo/internal/test	0.392s
ok  	cmd/cgo/internal/test	0.571s
ok  	cmd/cgo/internal/test	0.784s

##### API release note check
ok  	cmd/relnote	0.387s

##### API check
ok  	cmd/api	46.366s

##### GOMAXPROCS=2 runtime -cpu=1 -quick
ok  	runtime	10.165s

##### GOMAXPROCS=2 runtime -cpu=2 -quick
ok  	runtime	8.761s

##### GOMAXPROCS=2 runtime -cpu=4 -quick
ok  	runtime	7.142s

##### Testing race detector
ok  	runtime/race	11.347s
ok  	flag	2.033s
ok  	net	2.037s
ok  	os	2.218s
ok  	os/exec	3.052s
ok  	encoding/gob	1.852s
# flag.test
ld: warning: '/private/var/folders/sv/rs_453y57xj86xsbz3kw1mbc0000gn/T/go-link-828145511/000000.o' has malformed LC_DYSYMTAB, expected 98 undefined symbols to start at index 1626, found 95 undefined symbols starting at index 1626
ok  	flag	2.320s
# os/exec.test
ld: warning: '/private/var/folders/sv/rs_453y57xj86xsbz3kw1mbc0000gn/T/go-link-3461020076/000000.o' has malformed LC_DYSYMTAB, expected 98 undefined symbols to start at index 1626, found 95 undefined symbols starting at index 1626
ok  	os/exec	3.309s

##### ../test
ok  	cmd/internal/testdir	200.819s

ALL TESTS PASSED
---
Installed Go for darwin/arm64 in /Users/andig/htdocs/go2
Installed commands in /Users/andig/htdocs/go2/bin
*** You need to add /Users/andig/htdocs/go2/bin to your PATH.

@Jorropo
Copy link
Member

Jorropo commented Dec 29, 2024

1.24 results:
image
1.23 results:
image

I just got a failure on my linux/amd64 using 1.23.4, I'll bisect to see if I can find an exact fix altho it'll take a while to run.

@andig
Copy link
Contributor

andig commented Dec 29, 2024

Running sample program with race detector:

gotip run -race test.go

==================
WARNING: DATA RACE

Write at 0x00c000114000 by goroutine 99446:
  main.clone()
      /Users/andig/htdocs/evcc/test.go:29 +0x150
  main.main.func1()
      /Users/andig/htdocs/evcc/test.go:58 +0x94

Previous read at 0x00c000114000 by goroutine 99430:
  main.clone()
      /Users/andig/htdocs/evcc/test.go:29 +0x98
  main.main.func1()
      /Users/andig/htdocs/evcc/test.go:58 +0x94

Goroutine 99446 (running) created at:
  main.main()
      /Users/andig/htdocs/evcc/test.go:54 +0x268

Goroutine 99430 (running) created at:
  main.main()
      /Users/andig/htdocs/evcc/test.go:54 +0x268
==================
==================
WARNING: DATA RACE
Read at 0x00c01b7fc000 by goroutine 99446:
  main.clone()
      /Users/andig/htdocs/evcc/test.go:31 +0x20c
  main.main.func1()
      /Users/andig/htdocs/evcc/test.go:58 +0x94

Previous write at 0x00c01b7fc000 by goroutine 99430:
  runtime.slicecopy()
      /Users/andig/sdk/gotip/src/runtime/slice.go:355 +0x0
  slices.Clone[go.shape.[]main.Child,go.shape.struct { Err error; Something string; Toy *main.Toy; N int }]()
      /Users/andig/sdk/gotip/src/slices/slices.go:355 +0x120
  main.clone()
      /Users/andig/htdocs/evcc/test.go:29 +0x98
  main.main.func1()
      /Users/andig/htdocs/evcc/test.go:58 +0x94

Goroutine 99446 (running) created at:
  main.main()
      /Users/andig/htdocs/evcc/test.go:54 +0x268

Goroutine 99430 (finished) created at:
  main.main()
      /Users/andig/htdocs/evcc/test.go:54 +0x268
==================
==================
WARNING: DATA RACE
Write at 0x00c000114000 by goroutine 99450:
  main.clone()
      /Users/andig/htdocs/evcc/test.go:29 +0x150
  main.main.func1()
      /Users/andig/htdocs/evcc/test.go:58 +0x94

Previous read at 0x00c000114000 by goroutine 99341:
  main.main.func1()
      /Users/andig/htdocs/evcc/test.go:60 +0x2a0

Goroutine 99450 (running) created at:
  main.main()
      /Users/andig/htdocs/evcc/test.go:54 +0x268

Goroutine 99341 (running) created at:
  main.main()
      /Users/andig/htdocs/evcc/test.go:54 +0x268
==================
==================
WARNING: DATA RACE
Read at 0x00c01bf60090 by goroutine 99422:
  runtime.slicecopy()
      /Users/andig/sdk/gotip/src/runtime/slice.go:355 +0x0
  slices.Clone[go.shape.[]main.Child,go.shape.struct { Err error; Something string; Toy *main.Toy; N int }]()
      /Users/andig/sdk/gotip/src/slices/slices.go:355 +0x120
  main.clone()
      /Users/andig/htdocs/evcc/test.go:29 +0x98
  main.main.func1()
      /Users/andig/htdocs/evcc/test.go:58 +0x94

Previous write at 0x00c01bf60090 by goroutine 99341:
  runtime.slicecopy()
      /Users/andig/sdk/gotip/src/runtime/slice.go:355 +0x0
  slices.Clone[go.shape.[]main.Child,go.shape.struct { Err error; Something string; Toy *main.Toy; N int }]()
      /Users/andig/sdk/gotip/src/slices/slices.go:355 +0x120
  main.clone()
      /Users/andig/htdocs/evcc/test.go:29 +0x98
  main.main.func1()
      /Users/andig/htdocs/evcc/test.go:58 +0x94

Goroutine 99422 (running) created at:
  main.main()
      /Users/andig/htdocs/evcc/test.go:54 +0x268

Goroutine 99341 (running) created at:
  main.main()
      /Users/andig/htdocs/evcc/test.go:54 +0x268
==================
==================
WARNING: DATA RACE
Write at 0x00c000114000 by goroutine 99322:
  main.clone()
      /Users/andig/htdocs/evcc/test.go:29 +0x150
  main.main.func1()
      /Users/andig/htdocs/evcc/test.go:58 +0x94

Previous write at 0x00c000114000 by goroutine 99430:
  main.main.func1()
      /Users/andig/htdocs/evcc/test.go:60 +0x2e8

Goroutine 99322 (running) created at:
  main.main()
      /Users/andig/htdocs/evcc/test.go:54 +0x268

Goroutine 99430 (finished) created at:
  main.main()
      /Users/andig/htdocs/evcc/test.go:54 +0x268
==================
==================
WARNING: DATA RACE
Write at 0x00c000114000 by goroutine 99450:
  main.main.func1()
      /Users/andig/htdocs/evcc/test.go:60 +0x2e8

Previous read at 0x00c000114000 by goroutine 99422:
  main.clone()
      /Users/andig/htdocs/evcc/test.go:29 +0x98
  main.main.func1()
      /Users/andig/htdocs/evcc/test.go:58 +0x94

Goroutine 99450 (running) created at:
  main.main()
      /Users/andig/htdocs/evcc/test.go:54 +0x268

Goroutine 99422 (running) created at:
  main.main()
      /Users/andig/htdocs/evcc/test.go:54 +0x268
==================
==================
WARNING: DATA RACE
Write at 0x00c01b97e050 by goroutine 99446:
  main.clone()
      /Users/andig/htdocs/evcc/test.go:32 +0x268
  main.main.func1()
      /Users/andig/htdocs/evcc/test.go:58 +0x94

Previous write at 0x00c01b97e050 by goroutine 99450:
  runtime.slicecopy()
      /Users/andig/sdk/gotip/src/runtime/slice.go:355 +0x0
  slices.Clone[go.shape.[]main.Child,go.shape.struct { Err error; Something string; Toy *main.Toy; N int }]()
      /Users/andig/sdk/gotip/src/slices/slices.go:355 +0x120
  main.clone()
      /Users/andig/htdocs/evcc/test.go:29 +0x98
  main.main.func1()
      /Users/andig/htdocs/evcc/test.go:58 +0x94

Goroutine 99446 (running) created at:
  main.main()
      /Users/andig/htdocs/evcc/test.go:54 +0x268

Goroutine 99450 (running) created at:
  main.main()
      /Users/andig/htdocs/evcc/test.go:54 +0x268
==================
==================
WARNING: DATA RACE
Write at 0x00c000114000 by goroutine 99323:
  main.clone()
      /Users/andig/htdocs/evcc/test.go:29 +0x150
  main.main.func1()
      /Users/andig/htdocs/evcc/test.go:58 +0x94

Previous write at 0x00c000114000 by goroutine 99192:
  main.clone()
      /Users/andig/htdocs/evcc/test.go:29 +0x150
  main.main.func1()
      /Users/andig/htdocs/evcc/test.go:58 +0x94

Goroutine 99323 (running) created at:
  main.main()
      /Users/andig/htdocs/evcc/test.go:54 +0x268

Goroutine 99192 (finished) created at:
  main.main()
      /Users/andig/htdocs/evcc/test.go:54 +0x268
==================
==================
WARNING: DATA RACE
Write at 0x00c000114000 by goroutine 99332:
  main.clone()
      /Users/andig/htdocs/evcc/test.go:29 +0x150
  main.main.func1()
      /Users/andig/htdocs/evcc/test.go:58 +0x94

Previous read at 0x00c000114000 by goroutine 99420:
  main.clone()
      /Users/andig/htdocs/evcc/test.go:31 +0x194
  main.main.func1()
      /Users/andig/htdocs/evcc/test.go:58 +0x94

Goroutine 99332 (running) created at:
  main.main()
      /Users/andig/htdocs/evcc/test.go:54 +0x268

Goroutine 99420 (running) created at:
  main.main()
      /Users/andig/htdocs/evcc/test.go:54 +0x268
==================
==================
WARNING: DATA RACE
Write at 0x00c000114000 by goroutine 99304:
  main.main.func1()
      /Users/andig/htdocs/evcc/test.go:60 +0x2e8

Previous read at 0x00c000114000 by goroutine 99332:
  main.clone()
      /Users/andig/htdocs/evcc/test.go:31 +0x194
  main.main.func1()
      /Users/andig/htdocs/evcc/test.go:58 +0x94

Goroutine 99304 (running) created at:
  main.main()
      /Users/andig/htdocs/evcc/test.go:54 +0x268

Goroutine 99332 (running) created at:
  main.main()
      /Users/andig/htdocs/evcc/test.go:54 +0x268
==================
==================
WARNING: DATA RACE
Write at 0x00c000114000 by goroutine 99343:
  main.clone()
      /Users/andig/htdocs/evcc/test.go:29 +0x150
  main.main.func1()
      /Users/andig/htdocs/evcc/test.go:58 +0x94

Previous read at 0x00c000114000 by goroutine 99332:
  main.clone()
      /Users/andig/htdocs/evcc/test.go:32 +0x23c
  main.main.func1()
      /Users/andig/htdocs/evcc/test.go:58 +0x94

Goroutine 99343 (running) created at:
  main.main()
      /Users/andig/htdocs/evcc/test.go:54 +0x268

Goroutine 99332 (running) created at:
  main.main()
      /Users/andig/htdocs/evcc/test.go:54 +0x268
==================
==================
WARNING: DATA RACE
Read at 0x00c01bb7a1e0 by goroutine 99332:
  slices.IndexFunc[go.shape.[]main.Child,go.shape.struct { Err error; Something string; Toy *main.Toy; N int }]()
      /Users/andig/sdk/gotip/src/slices/slices.go:109 +0x78
  slices.DeleteFunc[go.shape.[]main.Child,go.shape.struct { Err error; Something string; Toy *main.Toy; N int }]()
      /Users/andig/sdk/gotip/src/slices/slices.go:237 +0x38
  main.main.func1()
      /Users/andig/htdocs/evcc/test.go:60 +0x2d4

Previous write at 0x00c01bb7a1e0 by goroutine 99409:
  runtime.slicecopy()
      /Users/andig/sdk/gotip/src/runtime/slice.go:355 +0x0
  slices.Clone[go.shape.[]main.Child,go.shape.struct { Err error; Something string; Toy *main.Toy; N int }]()
      /Users/andig/sdk/gotip/src/slices/slices.go:355 +0x120
  main.clone()
      /Users/andig/htdocs/evcc/test.go:29 +0x98
  main.main.func1()
      /Users/andig/htdocs/evcc/test.go:58 +0x94

Goroutine 99332 (running) created at:
  main.main()
      /Users/andig/htdocs/evcc/test.go:54 +0x268

Goroutine 99409 (running) created at:
  main.main()
      /Users/andig/htdocs/evcc/test.go:54 +0x268
==================
==================
WARNING: DATA RACE
Write at 0x00c000114000 by goroutine 99551:
  main.main.func1()
      /Users/andig/htdocs/evcc/test.go:60 +0x2e8

Previous read at 0x00c000114000 by goroutine 99332:
  main.main.func1()
      /Users/andig/htdocs/evcc/test.go:60 +0x2a0

Goroutine 99551 (running) created at:
  main.main()
      /Users/andig/htdocs/evcc/test.go:54 +0x268

Goroutine 99332 (running) created at:
  main.main()
      /Users/andig/htdocs/evcc/test.go:54 +0x268
==================
==================
WARNING: DATA RACE
Read at 0x00c000114000 by goroutine 99563:
  main.clone()
      /Users/andig/htdocs/evcc/test.go:32 +0x23c
  main.main.func1()
      /Users/andig/htdocs/evcc/test.go:58 +0x94

Previous write at 0x00c000114000 by goroutine 99436:
  main.main.func1()
      /Users/andig/htdocs/evcc/test.go:60 +0x2e8

Goroutine 99563 (running) created at:
  main.main()
      /Users/andig/htdocs/evcc/test.go:54 +0x268

Goroutine 99436 (finished) created at:
  main.main()
      /Users/andig/htdocs/evcc/test.go:54 +0x268
==================
==================
WARNING: DATA RACE
Write at 0x00c000114000 by goroutine 99194:
  main.main.func1()
      /Users/andig/htdocs/evcc/test.go:60 +0x2e8

Previous write at 0x00c000114000 by goroutine 99472:
  main.main.func1()
      /Users/andig/htdocs/evcc/test.go:60 +0x2e8

Goroutine 99194 (running) created at:
  main.main()
      /Users/andig/htdocs/evcc/test.go:54 +0x268

Goroutine 99472 (finished) created at:
  main.main()
      /Users/andig/htdocs/evcc/test.go:54 +0x268
==================
Found 15 data race(s)
exit status 66

@andig
Copy link
Contributor

andig commented Dec 29, 2024

Is this just invalid due to the race in DeleteFunc?

@Jorropo
Copy link
Member

Jorropo commented Dec 29, 2024

Thx for that, I somehow red go { for { ... } } rather than for { go { ... } } yes this program is invalid ❇️.
Idk why it doesn't fail on CI with go1.24 but that doesn't matter either way.

@Jorropo Jorropo closed this as not planned Won't fix, can't repro, duplicate, stale Dec 29, 2024
@Jorropo
Copy link
Member

Jorropo commented Dec 29, 2024

And that explains why it does not work exclusively with the buggy clone implementation as it doesn't clone the object which allows the race.

@raphaelvigee
Copy link
Author

it does fail on 1.24:

$ GOTOOLCHAIN=go1.24rc1 go run 'prtslicebug.go'
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x103063de0]

goroutine 96492 [running]:
main.clone(...)
        prtslicebug.go:30
main.main.func1()
        prtslicebug.go:56 +0x180
created by main.main in goroutine 1
        prtslicebug.go:52 +0x118
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x103063de0]

goroutine 97142 [running]:
main.clone(...)
        prtslicebug.go:30
main.main.func1()
        prtslicebug.go:56 +0x180
created by main.main in goroutine 1
        prtslicebug.go:52 +0x118
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x103063de0]

goroutine 96426 [running]:
main.clone(...)
        prtslicebug.go:30
main.main.func1()
        prtslicebug.go:56 +0x180
created by main.main in goroutine 1
        prtslicebug.go:52 +0x118
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x103063de0]

goroutine 96581 [running]:
main.clone(...)
        prtslicebug.go:30
main.main.func1()
        prtslicebug.go:56 +0x180
created by main.main in goroutine 1
        prtslicebug.go:52 +0x118
exit status 2

@raphaelvigee
Copy link
Author

So the bottom line is that there is this urban legend going around that &(*value) does give you a pointer of a copy of value, and for some CPU reason it only happens on darwin/armd64 ?

@Jorropo
Copy link
Member

Jorropo commented Dec 29, 2024

The clone never happens this leads to a datarace when doing p.Children =,
but for some reason darwin-arm64 1.23 is way more likely to crash than the rest.

The datarace is the crash, and it dataraces because as you pointed out there is urban legend that &(*value) gives you a copy which does not.

@raphaelvigee
Copy link
Author

Hum, very interesting, learnt something new today, thanks for the quick turnaround!

@Jorropo
Copy link
Member

Jorropo commented Dec 29, 2024

just so you know next time you should ask on one of the things listed on https://go.dev/wiki/Questions

@thepudds
Copy link
Contributor

Note that staticcheck reports this as SA4001:

main.go:23:7: &*x will be simplified to x. It will not copy x. (SA4001)
main.go:32:23: &*x will be simplified to x. It will not copy x. (SA4001)

which corresponds to these lines:

	p := &(*input)
	p.Children[i].Toy = &(*child.Toy)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime.
Projects
None yet
Development

No branches or pull requests

7 participants