Skip to content

x/sync/errgroup: no trace info is shown when nil pointer dereference occurs #73710

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
hajimehoshi opened this issue May 14, 2025 · 5 comments
Closed
Labels
BugReport Issues describing a possible bug in the Go implementation. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@hajimehoshi
Copy link
Member

Go version

go version go1.24.3 darwin/arm64

Output of go env in your module/workspace:

AR='ar'
CC='clang'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='clang++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/hajimehoshi/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/hajimehoshi/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/cj/73zbb35j0qx5t4b6rnqq0__h0000gn/T/go-build2637291888=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/Users/hajimehoshi/rpgsnack/runtime/go.mod'
GOMODCACHE='/Users/hajimehoshi/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/hajimehoshi/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='on'
GOTELEMETRYDIR='/Users/hajimehoshi/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.24.3'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

Run this with golang.org/x/sync v0.14.0 (https://go.dev/play/p/MWWuvzsPYXs)

package main

import (
	"fmt"

	"golang.org/x/sync/errgroup"
)

func main() {
	var g errgroup.Group
	var x *int
	g.Go(func() error {
		*x = 1
		return nil
	})
	if err := g.Wait(); err != nil {
		fmt.Printf("%#v", err)
	}
}

What did you see happen?

panic: recovered from errgroup.Group: runtime error: invalid memory address or nil pointer dereference

goroutine 1 [running]:
golang.org/x/sync/errgroup.(*Group).Wait(0xc00006a1e0)
	/tmp/gopath3257435728/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:70 +0x6d
main.main()
	/tmp/sandbox1006481412/prog.go:16 +0x85

and this doesn't tell where this dereference occurs

What did you expect to see?

In v0.13.0 (https://go.dev/play/p/k7rMoNy82F0) there was an info to know that

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x493264]

goroutine 6 [running]:
main.main.func1()
	/tmp/sandbox193375590/prog.go:13 +0x4
golang.org/x/sync/errgroup.(*Group).Go.func1()
	/tmp/gopath784252627/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:79 +0x50
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 1
	/tmp/gopath784252627/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:76 +0x93

Related: #53757

@gopherbot gopherbot added this to the Unreleased milestone May 14, 2025
@hajimehoshi
Copy link
Member Author

By the way, with 0.14.0, just a panic worked as expected (https://go.dev/play/p/z_TriF0xHr2):

package main

import (
	"fmt"

	"golang.org/x/sync/errgroup"
)

func main() {
	var g errgroup.Group
	g.Go(func() error {
		panic("foo")
	})
	if err := g.Wait(); err != nil {
		fmt.Printf("%#v", err)
	}
}
panic: recovered from errgroup.Group: foo
	goroutine 18 [running]:
	runtime/debug.Stack()
		/usr/local/go-faketime/src/runtime/debug/stack.go:26 +0x5e
	golang.org/x/sync/errgroup.(*Group).add.func1.1()
		/tmp/gopath4184341562/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:124 +0x139
	panic({0x49d720?, 0x4dc3a8?})
		/usr/local/go-faketime/src/runtime/panic.go:792 +0x132
	main.main.func1()
		/tmp/sandbox2035858750/prog.go:12 +0x25
	golang.org/x/sync/errgroup.(*Group).add.func1()
		/tmp/gopath4184341562/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:130 +0x7e
	created by golang.org/x/sync/errgroup.(*Group).add in goroutine 1
		/tmp/gopath4184341562/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:98 +0x76
	

goroutine 1 [running]:
golang.org/x/sync/errgroup.(*Group).Wait(0xc0000ac120)
	/tmp/gopath4184341562/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:70 +0x6d
main.main()
	/tmp/sandbox2035858750/prog.go:14 +0x55

@gabyhelp gabyhelp added the BugReport Issues describing a possible bug in the Go implementation. label May 14, 2025
@seankhliao
Copy link
Member

This is from #53757
cc @alandonovan @qiulaidongfeng @bcmills

The propagated panic is an errgroup.PanicError which by default doesn't include a stack trace in its stringified form.

https://go.dev/play/p/EZc7sD225Wq

@qiulaidongfeng
Copy link
Member

Thanks report.
I will send fix.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/672635 mentions this issue: sync/errgroup: PanicError.Error print stack trace

@mknyszek mknyszek added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label May 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BugReport Issues describing a possible bug in the Go implementation. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

6 participants