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

GodotString in virtual method parameters crash godot unless forgotten #195

Closed
lilizoey opened this issue Mar 21, 2023 · 1 comment · Fixed by #204
Closed

GodotString in virtual method parameters crash godot unless forgotten #195

lilizoey opened this issue Mar 21, 2023 · 1 comment · Fixed by #204
Labels
bug c: engine Godot classes (nodes, resources, ...) ub Undefined behavior

Comments

@lilizoey
Copy link
Member

lilizoey commented Mar 21, 2023

When implementing a virtual method that has a GodotString as a parameter, you need to do std::mem::forget() on that parameter, otherwise godot will crash.

Example of implementing ScriptLanguageExtensionVirtual::validate_path:

// additional validation on file-paths, return empty string for no error
fn validate_path(&self, path: GodotString) -> GodotString {
    println!("extension validate_path");
    std::mem::forget(path);
    GodotString::from("")
}

im here also adding a custom patch to gdextension where i just add in the return types for virtual methods (because of #190). it's fairly fragile and has some issues atm. but shouldn't interfere with this issue at hand, might clean that patch up at some point and upstream it.

@Bromeon Bromeon added bug c: engine Godot classes (nodes, resources, ...) labels Mar 21, 2023
@lilizoey
Copy link
Member Author

this also happens with pointer calls in general it seems

@bors bors bot closed this as completed in afbd2cd Apr 12, 2023
@Bromeon Bromeon added the ub Undefined behavior label Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug c: engine Godot classes (nodes, resources, ...) ub Undefined behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants