-
-
Notifications
You must be signed in to change notification settings - Fork 224
No helpful message on C++ stack overflow #1066
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
Comments
This example causes never-ending loop which actually causes the crash (Crasher creates CrasherChild and vice versa); It should happen in the editor as well. This issue will be rendered null after #1051 will be merged (i.e in 0.3.0 release) – it will remove See also: #892 |
i dont see why removing the |
Oh, my bad, the discord example included the Same use case appeared in the now hidden repo. The question is if anything can be done about that – should we permit using |
i dont think we can prevent it though. rust doesn't have any non-intrusive way to stop a type from being used as a field in a struct. |
You can use a proc-macro to detect if it's self-referential but this requires both structs to have this proc-macro. This could be done with GodotClass. This is probably over-cumbersome though. |
yeah but it also doesn't work with indirection. the above code is also fine as long as it's not cyclic, and there are cases where you might want that. which also increases the complexity of detecting this, either needing an opt-out or cycle detection, and it's not easy to reliably share state between macros invocations. we might be able to detect a cycle and error out early, or at least give a better error message. but we can't in general detect all infinite loops. |
@lemonlambda You're writing the godot-rust equivalent of this code*: #[derive(Default)]
struct Parent {
child: Box<Child>,
}
#[derive(Default)]
struct Child {
parent: Box<Parent>,
}
fn main() {
let _crash = Parent::default();
} I don't really see why/how we should try to prevent this? |
At least with-in rust you will get a stack overflow error, with godot you will just get a crash with no meaningful error. I guess that's my main problem. |
That's a Godot problem though, no? The equivalent GDScript probably has the same behavior? Or what should the Rust bindings concretely do to detect and act on such cases? |
I have no clue. Maybe it is a godot issue instead and should report it as so. |
Can you try reproducing it in GDScript? |
i was curious so i checked my code: # in node1.gd
class_name Node1
extends Node
var node: Node2 = Node2.new()
# in node2.gd
class_name Node2
extends Node
var node: Node1 = Node1.new() after adding to a scene and then running that scene, the game immediately stops running and a stack overflow error is displayed in the editor: |
Thanks for checking! It looks like the GDScript runtime has its own stack, which it can check. It even displayes the size (1024). If I run my example in a thread 'test_fn' has overflowed its stack
fatal runtime error: stack overflow But this is best-effort, not guaranteed, see here. It may also vary between platforms. If I run the same example (nothing with Godot!) in an Process finished with exit code 139 (interrupted by signal 11:SIGSEGV) which is probably a consequence of our code being hosted by Godot, a C++ application with different handling of stack overflow. To sum up:
In other words, I still don't see what godot-rust can realistically do against this. Maybe Godot can improve something and make stack overflows visible in its crash handler. But that would then be an issue to be taken up with the engine itself. So unless someone comes up with a concrete idea how we can handle this better, I'd tend to close this issue. |
I brought this up in Godot's RocketChat, there were some interesting answers. It was suggested that This is out of scope for godot-rust though, as it needs to be configured in the host application (Godot). If someone wants to pursue this, I'd recommend opening a Godot proposal with concrete requirements + maybe even ideas for design. Thanks for reporting, I learned quite a few things! 🙂 |
This causes godot 4.3 to crash even if the node(s) don't exist in the scene. A warning or an error for this would be nice if possible.
The text was updated successfully, but these errors were encountered: