Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

storage: fix alignement panics on 32 bit arch #1460

Merged
merged 1 commit into from
Jun 12, 2019
Merged

storage: fix alignement panics on 32 bit arch #1460

merged 1 commit into from
Jun 12, 2019

Conversation

skylenet
Copy link
Contributor

@skylenet skylenet commented Jun 12, 2019

Attempt on fixing the following panic which is happening on the 32 bit test runs on windows:

e.g.: https://ci.appveyor.com/project/ethersphere/swarm/builds/25220636/job/ueh5r89mvapmfq48

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x4028cc]
goroutine 498 [running]:
runtime/internal/atomic.Xadd64(0x13bfc62c, 0x1, 0x0, 0x4b, 0x1008)
	C:/go/src/runtime/internal/atomic/asm_386.s:105 +0xc
github.com/ethersphere/swarm/storage.(*hasherStore).storeChunk(0x13bfc600, 0xef55a0, 0x1393f240, 0xef0210, 0x1393f440)
	C:/gopath/src/github.com/ethersphere/swarm/storage/hasherstore.go:245 +0x36
github.com/ethersphere/swarm/storage.(*hasherStore).Put(0x13bfc600, 0xef55a0, 0x1393f240, 0x1c44f300, 0x4b, 0x1008, 0x13bfc6c0, 0xa, 0x10, 0x1eb, ...)
	C:/gopath/src/github.com/ethersphere/swarm/storage/hasherstore.go:84 +0x89
github.com/ethersphere/swarm/storage.(*PyramidChunker).processChunk(0x13468fc0, 0xef55a0, 0x1393f240, 0x1, 0x0, 0x1393f2c0)
	C:/gopath/src/github.com/ethersphere/swarm/storage/pyramid.go:286 +0x6d
github.com/ethersphere/swarm/storage.(*PyramidChunker).processor(0x13468fc0, 0xef55a0, 0x1393f240, 0x1, 0x0)
	C:/gopath/src/github.com/ethersphere/swarm/storage/pyramid.go:277 +0x71
created by github.com/ethersphere/swarm/storage.(*PyramidChunker).prepareChunks
	C:/gopath/src/github.com/ethersphere/swarm/storage/pyramid.go:392 +0xb9
FAIL	github.com/ethersphere/swarm	0.684s
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x4028cc]

On ARM, x86-32, and 32-bit MIPS, it is the caller's responsibility to arrange for 64-bit alignment of 64-bit words accessed atomically. The first word in a variable or in an allocated struct, array, or slice can be relied upon to be 64-bit aligned.

https://golang.org/pkg/sync/atomic/#pkg-note-BUG

@skylenet skylenet requested review from acud and nonsense June 12, 2019 10:16
@skylenet
Copy link
Contributor Author

32 bit run on Appveyor seems to have passed. I've re triggered the other jobs that failed due to a flaky test.

This also brought me to the attention on how important it is to have the CI target a 32 bit architecture so that we can identify these problems quickly.

@skylenet skylenet merged commit b3f6014 into master Jun 12, 2019
@bzzbot bzzbot added this to the 0.4.1 milestone Jun 13, 2019
@skylenet skylenet deleted the fix-32-bits branch June 14, 2019 12:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants