Open Kyrio opened 2 years ago
What happens if you change int ExampleRequest::request_list(const String &url)
to use String url
? (without the const
and without the &
)
Other note (but likely not cause of the crash), in the dummy function, c_url
is a dangling pointer because the CharString owning it is allocated as a temporary, which will get destroyed after url.utf8().get_data();
is evaluated.
Sorry for not being able to answer. Since I opened this issue, many versions came out including beta1 and I figured it would be wise to reproduce it on the latest. But so far I haven't been able to use a GDExtension without the game or the editor crashing in beta1, so testing has been difficult 😕
I will update as soon as I get my project working.
Actually it might be caused by https://github.com/godotengine/godot-cpp/issues/842
For the record, I have a function
inline std::string gd_to_std(const godot::String &src) {
return std::string{src.ascii().get_data()};
}
that is also only causing crashes on release builds. Changing the signature to std::string(godot::String)
(dropping ref and qualifiers) did not change this behaviour. I hope #842 fixes it!
If I instead use
inline std::string gd_to_std(const godot::String &src) {
const auto buf = src.to_ascii_buffer();
return std::string{buf.ptr(), buf.ptr() + buf.size()};
}
this sidesteps creating or destroying a CharString
(as buf
is a PackedByteArray
) and works fine. I'm only dealing with ASCII strings so I don't care too much about to_ascii_buffer
dropping characters.
(... uh, is there a better way to convert GD to stdlib strings...?)
Godot version
v4.0.alpha.custom_build [7355dfb] godot-cpp master [8ba1c05]
System information
Linux 64-bit (Solus), also reproduced on Windows 10 64-bit Export templates: Linux x64 release, Windows x64 release
Issue description
A crash occurs in my GDExtension exclusively in release exports. To obtain a stack trace I built my own export template with
target=release debug_symbols=yes
and the debug build of my gdextension. The attached project is equivalent to my setup and reproduces the issue.Here is a dummy function that produces the crash:
And here is the stack trace:
Steps to reproduce
scons target=debug
Minimal reproduction project
CharString.zip