Put int64 as the first word in Loop (#396)

Fix a bug with ARM and x86-32 and use of atomic operations on 64-bit values. More https://golang.org/pkg/sync/atomic/#pkg-note-BUG
This commit is contained in:
Adam Babik 2017-10-12 17:01:04 +02:00 committed by GitHub
parent 88294b29be
commit 12412b3f58
1 changed files with 5 additions and 1 deletions

View File

@ -39,9 +39,13 @@ type Task interface {
// aren't ready yet, keyed by their ID, and a channel of tasks that are ready
// to finalise on the VM. The channel holding the tasks pending finalising can
// be buffered or unbuffered.
//
// Warning: id must be the first field in this struct as it's accessed atomically.
// Otherwise, on ARM and x86-32 it will panic.
// More information: https://golang.org/pkg/sync/atomic/#pkg-note-BUG.
type Loop struct {
vm *vm.VM
id int64
vm *vm.VM
lock sync.RWMutex
tasks map[int64]Task
ready chan Task