Closed icexin closed 2 years ago
这段代码可以快速复现,原因在于缓存里面的block消息被修改了NextHash字段,于此同时另外一个协程在序列化block
func TestBrokenMessage(t *testing.T) {
for {
wg := sync.WaitGroup{}
wg.Add(2)
msg := new(pb.InternalBlock)
go func() {
defer wg.Done()
proto.Marshal(msg)
}()
go func() {
defer wg.Done()
msg.NextHash = []byte{'a'}
}()
wg.Wait()
}
}
xupercore version: https://github.com/xuperchain/xupercore/commit/cb95ad3570b2e52cf602f1332be0ec2ffa20d291 go version:
go version go1.16.5 linux/amd64
output: