Skip to content

Commit

Permalink
beacon-chain: fix segfault (#7822)
Browse files Browse the repository at this point in the history
Observed this segfault running all tests on mater, occurring
in around 2-3 out of 10 test runs.

```
FAIL: //beacon-chain/sync:go_default_test (shard 3 of 4, run 1 of 10) (see /home/j/.cache/bazel/_bazel_j/1ba834ca9d49f27aeb8f0bbb6f28fdf3/execroot/prysm/bazel-out/k8-fastbuild/testlogs/beacon-chain/sync/go_default_test/shard_3_of_4_run_1_of_10/test.log)
INFO: From Testing //beacon-chain/sync:go_default_test (shard 3 of 4, run 1 of 10):
==================== Test output for //beacon-chain/sync:go_default_test (shard 3 of 4, run 1 of 10):
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x138eea6]

goroutine 1660 [running]:
github.com/prysmaticlabs/prysm/shared/abool.(*AtomicBool).IsSet(...)
	shared/abool/abool.go:39
github.com/prysmaticlabs/prysm/beacon-chain/sync.(*Service).subscribeStaticWithSubnets.func1(0xc002dd4400, 0xc002990940, 0x17bca26, 0x1e)
	beacon-chain/sync/subscriber.go:207 +0xe6
created by github.com/prysmaticlabs/prysm/beacon-chain/sync.(*Service).subscribeStaticWithSubnets
	beacon-chain/sync/subscriber.go:200 +0x172
================================================================================
```

TestStaticSubnets was testing a Service with an uninitialized
chainStarted value. This commit initializes chainStarted explicitly
in all tests that construct a Service. This reduces the observed flake
rate to 0/10 runs. This was verified with:

```
./bazel.sh test //beacon-chain/sync:go_default_test --runs_per_test 10
```
  • Loading branch information
james-rms committed Nov 16, 2020
1 parent 977e539 commit 758ec96
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions beacon-chain/sync/subscriber_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ func TestRevalidateSubscription_CorrectlyFormatsTopic(t *testing.T) {
Genesis: time.Now(),
ValidatorsRoot: [32]byte{'A'},
},
p2p: p,
p2p: p,
chainStarted: abool.New(),
}
digest, err := r.forkDigest()
require.NoError(t, err)
Expand Down Expand Up @@ -241,7 +242,8 @@ func TestStaticSubnets(t *testing.T) {
Genesis: time.Now(),
ValidatorsRoot: [32]byte{'A'},
},
p2p: p,
p2p: p,
chainStarted: abool.New(),
}
defaultTopic := "/eth2/%x/beacon_attestation_%d"
r.subscribeStaticWithSubnets(defaultTopic, r.noopValidator, func(_ context.Context, msg proto.Message) error {
Expand Down

0 comments on commit 758ec96

Please sign in to comment.