Background: The method MatchStructure has a parameter lhs_base_index which is passed on to the call to Match which scans the structure by incrementing lhs_index. If Match comes across an I_PTR, then it recursively calls MatchStructure where the lhs_base_index is the position of the new structure, and where 0 is again passed for lhs_index.
MatchStructure is also called from CounterEvidence, but it is called incorrectly. It correctly uses lhs_atom.asIndex() as the position of the structure, but it should not pass MK_VAL_VALUE because MatchStructure adds the two together to get the wrong code position. This is a bug that can cause an out-of-bounds error which we have seen sometimes. (It doesn't occur often because it only happens when comparing mk.val where the value is a structure, like (mk.val h holding [s]) . If the value is a float then this part of the code isn't used.)
This pull request fixes CounterEvidence to call MatchStructure in the same way that Match does, as described above. This fixes the out-of-bounds error.
Background: The method
MatchStructure
has a parameterlhs_base_index
which is passed on to the call toMatch
which scans the structure by incrementinglhs_index
. IfMatch
comes across an I_PTR, then it recursively callsMatchStructure
where thelhs_base_index
is the position of the new structure, and where 0 is again passed forlhs_index
.MatchStructure
is also called fromCounterEvidence
, but it is called incorrectly. It correctly useslhs_atom.asIndex()
as the position of the structure, but it should not passMK_VAL_VALUE
becauseMatchStructure
adds the two together to get the wrong code position. This is a bug that can cause an out-of-bounds error which we have seen sometimes. (It doesn't occur often because it only happens when comparing mk.val where the value is a structure, like(mk.val h holding [s])
. If the value is a float then this part of the code isn't used.)This pull request fixes
CounterEvidence
to callMatchStructure
in the same way thatMatch
does, as described above. This fixes the out-of-bounds error.