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

Add test that checks if custom callables don't crash when Err() is returned. #950

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Yarwin
Copy link
Contributor

@Yarwin Yarwin commented Nov 10, 2024

Before #944 returning Err() with custom callable was causing crash without any sensible backtrace (both on windows 10 and linux):

================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.3.stable.official (77dcf97d82cbfe4e4615475fa52ca03da645dbd8)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7f64ce442520] (??:0)
[2] /home/irwin/apps/godot/godot/G4/Godot_v4.3-stable_linux.x86_64() [0x410be5c] (??:0)
[3] /home/irwin/apps/godot/godot/G4/Godot_v4.3-stable_linux.x86_64() [0x410c4a9] (??:0)
[4] /home/irwin/apps/godot/godot/G4/Godot_v4.3-stable_linux.x86_64() [0x4318e70] (??:0)
[5] /home/irwin/apps/godot/godot/G4/Godot_v4.3-stable_linux.x86_64() [0x232bafa] (??:0)
[6] /home/irwin/apps/godot/godot/G4/Godot_v4.3-stable_linux.x86_64() [0x232ba0e] (??:0)
[7] /home/irwin/apps/godot/godot/G4/Godot_v4.3-stable_linux.x86_64() [0x232ba0e] (??:0)
[8] /home/irwin/apps/godot/godot/G4/Godot_v4.3-stable_linux.x86_64() [0x232ba0e] (??:0)
[9] /home/irwin/apps/godot/godot/G4/Godot_v4.3-stable_linux.x86_64() [0x232ba0e] (??:0)
[10] /home/irwin/apps/godot/godot/G4/Godot_v4.3-stable_linux.x86_64() [0x232ba0e] (??:0)
[11] /home/irwin/apps/godot/godot/G4/Godot_v4.3-stable_linux.x86_64() [0x232ba0e] (??:0)
[12] /home/irwin/apps/godot/godot/G4/Godot_v4.3-stable_linux.x86_64() [0x232d0f8] (??:0)
[13] /home/irwin/apps/godot/godot/G4/Godot_v4.3-stable_linux.x86_64() [0x2347885] (??:0)
[14] /home/irwin/apps/godot/godot/G4/Godot_v4.3-stable_linux.x86_64() [0x4fe39a] (??:0)
[15] /home/irwin/apps/godot/godot/G4/Godot_v4.3-stable_linux.x86_64() [0x235e7fc] (??:0)
[16] /home/irwin/apps/godot/godot/G4/Godot_v4.3-stable_linux.x86_64() [0x23b64a5] (??:0)
[17] /home/irwin/apps/godot/godot/G4/Godot_v4.3-stable_linux.x86_64() [0x527ab4] (??:0)
[18] /home/irwin/apps/godot/godot/G4/Godot_v4.3-stable_linux.x86_64() [0x4202a2] (??:0)
[19] /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7f64ce429d90] (??:0)
[20] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80) [0x7f64ce429e40] (??:0)
[21] /home/irwin/apps/godot/godot/G4/Godot_v4.3-stable_linux.x86_64() [0x43d44a] (??:0)
-- END OF BACKTRACE --
================================================================

This PR adds an extra test case that should shield against the regression in the future.

@GodotRust
Copy link

API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-950

Copy link
Member

@Bromeon Bromeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since that PR changed from by-value to by-ref, it might be a use-after-free: I could imagine that a value didn't live long enough, and now does because it's retained on the call-site.

So thanks a lot, a regression test is definitely a good idea in case we change implementation again 👍

Comment on lines 197 to 198
// errors in godot but should not crash
assert_eq!(callable_with_err.callv(&varray![]), Variant::nil());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// errors in godot but should not crash
assert_eq!(callable_with_err.callv(&varray![]), Variant::nil());
// Errors in Godot, but should not crash.
assert_eq!(callable_with_err.callv(&varray![]), Variant::nil());

@Bromeon Bromeon added quality-of-life No new functionality, but improves ergonomics/internals c: core Core components labels Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: core Core components quality-of-life No new functionality, but improves ergonomics/internals
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants