-
-
Notifications
You must be signed in to change notification settings - Fork 654
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
Infinite recursion on stringification of objects with circular references #8113
Infinite recursion on stringification of objects with circular references #8113
Conversation
This would be good to fix for 4.0 because it frequently causes test confusion. |
@hughsando: Could you fix this for hxcpp? Here's a standalone test case: class Main {
static public function main() {
var o = {rec: (null : Dynamic)};
o.rec = o;
trace(Std.string(o));
}
}
|
Uhm, this fails on flash/as3 too. |
While we're at it, we should also check printing of recursive enum structures. |
…:RealyUniqueName/haxe into bugfix/7903-toString-circular-references
Added a test for recursive enums |
These targets fail recursive array check: neko, hl, java, cs, cpp (added a checklist to the first post) |
I'm not sure I'm willing to fix this in HL . Given toString() can be user implemented, it's quite easy for the user to create a stack overflow with simultaneous calls. For instance: class A {
public var me : A;
public function new() { me = this; };
public function toString() {
return "A"+me.toString();
}
static function main() {
trace(new A());
}
} I'm not sure why Array should be a specific case. |
I understand that. But as a user, I've faced frustrating situations when I've got infinite recursion without any custom toString involved. |
Well, HL have a VScode integrated debugger and the stack overflow should be correctly reported and catch. We want of course to avoid crash or eating all the memory, but I'm not sure how to test that exactly. |
Not sure why the fact that users can cause this would be an argument against fixing it in std. |
Yeah, this has got me many times over the years with many targets.
|
On other targets we limit the depth of recursion, so I think hxcpp should do that as well. |
This problem is reproduced in JS target. |
@RealyUniqueName Could you merge development again so we can see where we're at here? |
@Aurel300 Could you check the hxcpp hang? I think it's the last thing to address here. |
Maybe we should test that this works fine even if a |
* Prevent infinite recustion on Array.toString (HaxeFoundation/haxe#8113) * minor * codestyle
Fixes #7903.
PR to see which targets have the same issue.
Recursive objects:
Recursive arrays: