Skip to content
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

Although using the WaitGroup for synchronization, the goroutine is started but not executed #25583

Closed
redxio opened this issue May 26, 2018 · 3 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@redxio
Copy link

redxio commented May 26, 2018

Please answer these questions before submitting your issue. Thanks!

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

go version go1.10.2 linux/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/Mr.Liu/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/Mr.Liu/go"
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="0"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build589254160=/tmp/go-build -gno-record-gcc-switches"

What did you do?

split list into a couple of sublist without break link and then respectively start goroutine to reverse it simultaneously.
runable code for reproducing error:
https://play.golang.org/p/xjsf7UayQuC

What did you expect to see?

the whole linked list was successfully reversed

What did you see instead?

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

goroutine 20 [running]:
main.reverse(0xc420088080, 0xc420090000, 0xc420092000)
/home/Mr.Liu/go/src/local/stackoverflow/tmp.go:71 +0xb7
created by main.(*LinkedList).Reverse
/home/Mr.Liu/go/src/local/stackoverflow/tmp.go:88 +0x119

@davecheney
Copy link
Contributor

This looks like memory corruption. Have you tried running your program under the race detector? See https://blog.golang.org/race-detector .

@davecheney davecheney added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label May 26, 2018
@redxio
Copy link
Author

redxio commented May 26, 2018

@davecheney
The result of running program when enable race detector:

WARNING: DATA RACE
Write at 0x00c420092148 by goroutine 6:
main.reverse()
/home/Mr.Liu/go/src/local/stackoverflow/tmp.go:72 +0x17f

Previous read at 0x00c420092148 by goroutine 5:
main.splitList.func1()
/home/Mr.Liu/go/src/local/stackoverflow/tmp.go:54 +0x1e9

Goroutine 6 (running) created at:
main.(*LinkedList).Reverse()
/home/Mr.Liu/go/src/local/stackoverflow/tmp.go:88 +0x1ba
main.main()
/home/Mr.Liu/go/src/local/stackoverflow/tmp.go:108 +0x1eb

Goroutine 5 (finished) created at:
main.splitList()
/home/Mr.Liu/go/src/local/stackoverflow/tmp.go:34 +0xeb
main.(*LinkedList).Reverse()
/home/Mr.Liu/go/src/local/stackoverflow/tmp.go:85 +0x145
main.main()
/home/Mr.Liu/go/src/local/stackoverflow/tmp.go:108 +0x1eb

WARNING: DATA RACE
Write at 0x00c420092138 by goroutine 6:
main.reverse()
/home/Mr.Liu/go/src/local/stackoverflow/tmp.go:72 +0x17f

Previous read at 0x00c420092138 by goroutine 5:
main.splitList.func1()
/home/Mr.Liu/go/src/local/stackoverflow/tmp.go:40 +0xdc

Goroutine 6 (running) created at:
main.(*LinkedList).Reverse()
/home/Mr.Liu/go/src/local/stackoverflow/tmp.go:88 +0x1ba
main.main()
/home/Mr.Liu/go/src/local/stackoverflow/tmp.go:108 +0x1eb

Goroutine 5 (finished) created at:
main.splitList()
/home/Mr.Liu/go/src/local/stackoverflow/tmp.go:34 +0xeb
main.(*LinkedList).Reverse()
/home/Mr.Liu/go/src/local/stackoverflow/tmp.go:85 +0x145
main.main()
/home/Mr.Liu/go/src/local/stackoverflow/tmp.go:108 +0x1eb

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

goroutine 3 [running]:
main.reverse(0xc420098040, 0xc4200a0000, 0xc4200a2000)
/home/Mr.Liu/go/src/local/stackoverflow/tmp.go:71 +0x169
created by main.(*LinkedList).Reverse
/home/Mr.Liu/go/src/local/stackoverflow/tmp.go:88 +0x1bb

@agnivade
Copy link
Contributor

Please fix the data race. We can reopen if you still see an issue then. Thanks.

@golang golang locked and limited conversation to collaborators May 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants