Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object>>#hashcode recurses infinitely on objects with cyclic references #24

Open
Hirevo opened this issue Dec 11, 2021 · 0 comments
Open
Assignees
Labels
C-bug Category: Bugs M-interpreter Module: Interpreter P-medium Priority: Medium

Comments

@Hirevo
Copy link
Owner

Hirevo commented Dec 11, 2021

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
@Hirevo Hirevo added C-bug Category: Bugs M-interpreter Module: Interpreter P-medium Priority: Medium labels Dec 11, 2021
@Hirevo Hirevo self-assigned this Dec 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Bugs M-interpreter Module: Interpreter P-medium Priority: Medium
Projects
None yet
Development

No branches or pull requests

1 participant