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

runtime: Random golang memory corruption on all supported architectures. #23788

Closed
CaptainDero opened this issue Feb 12, 2018 · 8 comments

Comments

Projects
None yet
4 participants
@CaptainDero
Copy link

commented Feb 12, 2018

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

go version go1.9.2 linux/amd64
go 1.10 rc1

Does this issue reproduce with the latest release?

Yes

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

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

Bug affects all golang supported architectures.

What did you do?

It looks some undefined, uninitialized memory address is affecting the normal execution of the program. At first place program should not even get compiled.
See below for more details.
Bug can be reproduced by compiling following:
https://github.com/deroproject/derosuite/tree/master/cmd/derod
Pls see more details below:
https://github.com/deroproject/derosuite/blob/995d27eec249c7b3d908ebcf28af1449184c6cbf/crypto/ringct/mlsag.go#L161

If possible, provide a recipe for reproducing the error.
Comment Line no. 179 https://github.com/deroproject/derosuite/blob/995d27eec249c7b3d908ebcf28af1449184c6cbf/crypto/ringct/mlsag.go#L179
And
Uncomment Line no. 183 https://github.com/deroproject/derosuite/blob/995d27eec249c7b3d908ebcf28af1449184c6cbf/crypto/ringct/mlsag.go#L183

What did you expect to see?

Crypto checksums should get verified without any errors.

What did you see instead?

Crypto checksums starts failing randomly.

@CaptainDero CaptainDero changed the title Random golang crashes on all supported architectures. Random golang memory corruption on all supported architectures. Feb 12, 2018

@davecheney

This comment has been minimized.

Copy link
Contributor

commented Feb 12, 2018

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

@CaptainDero

This comment has been minimized.

Copy link
Author

commented Feb 12, 2018

If a compiler is using undeclared variable ,the bug does not fall in category of memory corruption. In this case compiler is using undeclared variable and thus the code should not even compile.

@davecheney

This comment has been minimized.

Copy link
Contributor

commented Feb 12, 2018

Can you please provide small self contained example of the compiler using an undeclared variable. Thanks.

@CaptainDero

This comment has been minimized.

Copy link
Author

commented Feb 12, 2018

I would have already submitted here but Its not easy to create a simple test case for this case. Have documented sufficiently here https://github.com/deroproject/derosuite/blob/995d27eec249c7b3d908ebcf28af1449184c6cbf/crypto/ringct/mlsag.go#L159

@davecheney

This comment has been minimized.

Copy link
Contributor

commented Feb 12, 2018

I don’t understand what you mean by an undeclared variable. Could you possibly write a small program in the playground to show this, it doesn’t need to reproduce the bug your demonstrated here.

Can you also try passing -gcflags=“-l -N” to disable optimisations and see if that affects the outcome.

@ALTree

This comment has been minimized.

Copy link
Member

commented Feb 12, 2018

The race detector barks at your project. I'm using $ go run -race main.go at derosuite/cmd/derod.

WARNING: DATA RACE
Read at 0x00c42017a250 by goroutine 17:
  main.main.func1()
      /home/adonizetti/gocode/src/github.com/deroproject/derosuite/blockchain/blockchain.go:181 +0xe9

Previous write at 0x00c42017a250 by goroutine 13:
  github.com/deroproject/derosuite/blockchain.(*Blockchain).Add_Complete_Block()
      /home/adonizetti/gocode/src/github.com/deroproject/derosuite/blockchain/blockchain.go:469 +0xd9c
  github.com/deroproject/derosuite/p2p.Handle_BC_Notify_Response_GetObjects()
      /home/adonizetti/gocode/src/github.com/deroproject/derosuite/p2p/bc_notify_response_get_objects.go:146 +0xd9a
  github.com/deroproject/derosuite/p2p.Handle_Connection()
      /home/adonizetti/gocode/src/github.com/deroproject/derosuite/p2p/levin.go:245 +0x1099
  github.com/deroproject/derosuite/p2p.P2P_engine()
      /home/adonizetti/gocode/src/github.com/deroproject/derosuite/p2p/controller.go:95 +0x737

Goroutine 17 (running) created at:
  main.main()
      /home/adonizetti/gocode/src/github.com/deroproject/derosuite/cmd/derod/main.go:118 +0xb9a

Goroutine 13 (running) created at:
  github.com/deroproject/derosuite/p2p.P2P_Init()
      /home/adonizetti/gocode/src/github.com/deroproject/derosuite/p2p/controller.go:38 +0x1db
  main.main()
      /home/adonizetti/gocode/src/github.com/deroproject/derosuite/cmd/derod/main.go:113 +0xb4a
==================

and several others.

@ALTree

This comment has been minimized.

Copy link
Member

commented Feb 12, 2018

It is also not true that the compiler is using undeclared variables. You wrote in the comment you linked:

if the variables are declared within first loop, second loop is able to access them without declaring them

If you comment line 179 here, the code in the second loop, at line 195, will start using variable L as declared in const.go, line 25. The L declaration outside the loops is shadowing the already-declared L in const.go.

@CaptainDero

This comment has been minimized.

Copy link
Author

commented Feb 12, 2018

Thanks for pointing out the mistake.

@mikioh mikioh changed the title Random golang memory corruption on all supported architectures. runtime: Random golang memory corruption on all supported architectures. Feb 21, 2018

@golang golang locked and limited conversation to collaborators Feb 21, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.