You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 15, 2018. It is now read-only.
Notice the bug there
if bA == nil, we invoke o.Copy(), of which o might also be nil. But the biggest problem even is that even if bA, we intended to return o.Copy() but instead forgot about the return and on the next line invoke bA.mtx.Lock() which delivers a crash to us.
We really need to make rigorous tests as it seems that we've been testing with the best conditions intended but in the wild we find the actual edge cases e.g nil arguments being passed in as in tendermint/tendermint#1169
The text was updated successfully, but these errors were encountered:
odeke-em
changed the title
common/BitArray: Or is buggy with a nil deference and mistaken nil check clause
common/BitArray: Or is buggy with a nil deference and mistaken nil check clause instead of a return
Feb 6, 2018
Fixes#145Fixes#146
The code in here has been fragile when it comes to nil
but these edge cases were never tested, although they've
showed up in the wild and were only noticed because
the reporter actually read the logs otherwise
we'd have never known.
This changes covers some of these cases and adds some tests.
I was just auditing the code and noticed that *BitArray.Or's code looks like this
tmlibs/common/bit_array.go
Lines 102 to 104 in 19e818f
Notice the bug there
if bA == nil, we invoke o.Copy(), of which o might also be nil. But the biggest problem even is that even if bA, we intended to return o.Copy() but instead forgot about the return and on the next line invoke bA.mtx.Lock() which delivers a crash to us.
We really need to make rigorous tests as it seems that we've been testing with the best conditions intended but in the wild we find the actual edge cases e.g nil arguments being passed in as in tendermint/tendermint#1169
The text was updated successfully, but these errors were encountered: