`Object>>#hashcode` recurses infinitely on objects with cyclic references
Hirevo opened this issue · comments
Nicolas Polomack commented
While working with graphs to test various pathfinding algorithms in SOM, I discovered that the current implementation of the Object>>#hashcode
primitive infinitely recurses, if the object contains a reference cycle anywhere in itself and/or in its locals.
Minimal example code:
CyclicDataTest = (
run: args = (
| first second |
first := Array new: 1.
second := Array new: 1.
first at: 1 put: second.
second at: 1 put: first.
" this call to `Object>>#hashcode` recurses infinitely until the stack overflows "
first hashcode println.
)
)
Running this code results in:
thread 'main' has overflowed its stack
fatal runtime error: stack overflow
Aborted