You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version)?
go1.5 windows/amd64
What operating system and processor architecture are you using (go env)?
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\slisovskyi\code\go
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GO15VENDOREXPERIMENT=
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
What did you do?
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
Iteration through list with RANGE and sending object pointer through channel - produces incorrect pointers.
Iteration by element index don't produce such bug.
I suggest it is garbage collector issue
the member here is a variable that gets reused for every iteration. When sending a pointer to that variable it will print whatever is in that variable at the moment its printed not what was in the variable when the pointer was taken.
If you add a delay after sending the pointer you will see that the output becomes different.
time.Sleep(100 * time.Millisecond)
With the delay the range loop usually wont be faster than the routine that selects and prints from the channel. This is only for demonstration of the effect not to be meant as solution to a problem.
Please answer these questions before submitting your issue. Thanks!
go version
)?go1.5 windows/amd64
go env
)?set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\slisovskyi\code\go
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GO15VENDOREXPERIMENT=
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
https://play.golang.org/p/Y2Sx72JHUZ
Iteration through list with RANGE and sending object pointer through channel - produces incorrect pointers.
Iteration by element index don't produce such bug.
I suggest it is garbage collector issue
------PTR {Name:A}
------PTR {Name:B}
------PTR {Name:C}
------PTR {Name:D}
------PTR {Name:B}
------PTR {Name:B}
------PTR {Name:D}
------PTR {Name:D}
The text was updated successfully, but these errors were encountered: