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
The dotty compiler crashed with an "ArrayIndexOutofBounds" exception in "getOrElseUpdate" on an AnyRefMap. I could not minimize it, but think I know where the failure comes from. Here's the code of getOrElseUpdate:
overridedefgetOrElseUpdate(key: K, defaultValue: =>V):V= {
valh= hashOf(key)
vali= seekEntryOrOpen(h, key)
if (i <0) {
valvalue= defaultValue
_size +=1valj= i & IndexMask
_hashes(j) = h
_keys(j) = key.asInstanceOf[AnyRef]
_values(j) = value.asInstanceOf[AnyRef]
if ((i & VacantBit) !=0) _vacant -=1elseif (imbalanced) repack()
value
}
else _values(i).asInstanceOf[V]
}
The error happens if the defaultValue computation causes a size increase and rehash of the map. In that case the value of i seems to be no longer valid.
The actual call causing the error was:
fwiw, I think this could plausibly have simply been closed as "wontfix". blowing up if you change the map out from under itself like this doesn't seem like a bug to me, necessarily. /cc @hrhino
One could wontfix it, but it has the unfriendly property then that m.getOrElseUpdate(k, f()) is not the same as the apparently logically equivalent if (!(m contains k)) m(k) = f(); m(k). Having to maintain the mental distinction is an unwelcome burden on the user.
The dotty compiler crashed with an "ArrayIndexOutofBounds" exception in "getOrElseUpdate" on an AnyRefMap. I could not minimize it, but think I know where the failure comes from. Here's the code of getOrElseUpdate:
The error happens if the defaultValue computation causes a size increase and rehash of the map. In that case the value of
i
seems to be no longer valid.The actual call causing the error was:
Indeed the default value expression
typer.typed(tree, pt)
could easily create enough newtypedTree
entries to cause a rehash.The text was updated successfully, but these errors were encountered: