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

SystemStackError on Hash#eql? with mutally recursive hashes #5531

Open
lopopolo opened this issue Aug 13, 2021 · 2 comments
Open

SystemStackError on Hash#eql? with mutally recursive hashes #5531

lopopolo opened this issue Aug 13, 2021 · 2 comments

Comments

@lopopolo
Copy link
Contributor

$ irb
mirb - Embeddable Interactive Ruby Shell

> RUBY_VERSION
 => "3.0"
> RUBY_ENGINE
 => "mruby"
> a = {} ; b = {}
 => {}
> a.merge! self: a, other: b ; nil
 => nil
> b.merge! self: b, other: a ; nil
 => nil
> a.eql? b
stack level too deep (SystemStackError)
@matz
Copy link
Member

matz commented Aug 13, 2021

It's mruby limitation. The recursive check requires memory, which can be very precious on mruby target platforms.
If you can think of memory-efficient implementation (like using the tortoise-and-hare algorithm), please tell me.

@matz
Copy link
Member

matz commented Sep 5, 2021

FYI, CPython also gives up a recursive comparison.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants