-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
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
Crash when calling std::cout in gdextension constructor #85959
Comments
Does it happen if you use the helper function for it? |
No crash when using UtilityFunctions::print("Hello world") I am currently converting my cpp sources to use godot:s print function instead of std::cout, there is quite some lines and formats to change. |
Can you also try with |
printf works. :) |
Then I think this can be closed, we don't recommend using the standard library in general and don't think we do on the godot-cpp page either, can be a trap for some but we do provide proper printing methods (which also work with the editor) so I think this is out of scope for what we support |
So does that mean using standard containers such as std::vector, and other classes, is not recommended as well? |
Not for the engine at least, you're free to do what ever you like in an extension 🙂, but we don't provide any guarantees of safety in using these things as we don't test for them AFAIK |
Okay, thanks, for the help. I will see what I can do to limit as much as possible from std library. |
Also, this might be due to error handling being turned off, which it is in both the engine and godot-cpp now days, and that's another reason to avoid the standard library as it depends heavily on errors |
I noticed that exceptions where not allowed aswell (error handling), as I am parsing some files and using std::stoi, which may throw things. I added this line in SConstruct: I am using exceptions in some of my classes aswell. I guess you want to avoid crashes and exceptions in Godot which is good, but that feels like impossible in C++ ... Off topic, right now I am trying to export my app to Android, but it does not work as well as I thought, even if I am compiling the Android library, and installing the app on my phone without any problems, Godot complains about my library is missing. |
You need to instead add This is probably what's causing this, you can't run error handling without changing these things |
Thanks. |
Thats not really an issue on our end, please try with enabled exceptions, and see, but we're not able to guarantee support universally |
Then I guess we are quite limited using other libraries, hence OpenCV will not work because it is writing logs with the standard library internally. But thanks anyway, I cannot request anything, as you are doing a great job with this awesome engine! Using disable_exceptions=false does indeed remove the exception compile errors. |
Did you build the engine as well? Also are you using the correct version of godot-cpp? |
But importantly: we can't (and don't) provide any guarantees of compatibility in general, but if you identify a specific issue that can be solved then you should report that But it needs to be specific, so if you identify some specific part of the code that makes using libraries hard then please report it, but in this case do so over here |
Just a note on this issue since I hadn't seen it when it came up originally: Using There seems to be some difference in the environment of users who are experiencing this crash, and we should get to the bottom of what that is. Let's continue working on this over on this godot-cpp issue: godotengine/godot-cpp#1326 |
Tested versions
Not reproducible in 4.1
Reproducible in 4.2
System information
Arch Linux 6.6.4-arch1-1 (64-bit)
Issue description
Crashing Godot if std::cout is called in a C++ class constructor using gdextension.
The call can be as simple as:
std::cout << "Hello World\n";
Removing it, Godot starts up.
Other calls to std::cout, which is not call in any initialization, I guess will just crash the application when running it from Godot.
================================================================
================================================================
Steps to reproduce
Add a call to std::cout in your gdextension constructor.
Minimal reproduction project (MRP)
gdtest.zip
The text was updated successfully, but these errors were encountered: