-
Notifications
You must be signed in to change notification settings - Fork 53
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
fix return-stack-address violations #143
Conversation
Do you have a log of the android crash ? I tested Android many times and never got one. |
@CedNaru Ill reproduce later today and provide logcat output if it helps. |
relevant logcat output from the second of the crash:
using play_one_shot_with_params will not crash, but instead print the following message (without playing a sound):
|
I never knew that registering const ref in Godot methods was ending up in that kind of issue (magic of C++ templates, I guess). But I see no issue with applying the changes. |
Yeah, don't know how to solve that. It seems that even having the person adding secrets on their own doesn't work. |
While building the project, the following warning appears multiple times:
../godot-cpp/include/core/Godot.hpp:163:10: warning: returning reference to local temporary object [-Wreturn-stack-address]
return a;
^
../godot-cpp/include/core/Godot.hpp:285:34: note: in instantiation of member function 'godot::_ArgCast<const godot::Array &>::_arg_cast' requested here
*ret = (obj->*f)(_ArgCast::_arg_cast(args[I])...);
^
../godot-cpp/include/core/Godot.hpp:310:10: note: in instantiation of function template specialization 'godot::_WrappedMethod<godot::Fmod, float, unsigned long, const godot::Array &>::apply<0, 1>' requested here
method->apply(var, obj, arg, typename __construct_sequence<sizeof...(As)>::type{});
^
../godot-cpp/include/core/Godot.hpp:325:34: note: in instantiation of function template specialization 'godot::__wrapped_method<godot::Fmod, float, unsigned long, const godot::Array &>' requested here
return (__godot_wrapper_method)&__wrapped_method<T, R, As...>;
^
../godot-cpp/include/core/Godot.hpp:343:42: note: in instantiation of function template specialization 'godot::___get_wrapper_function<godot::Fmod, float, unsigned long, const godot::Array &>' requested here
method.method = (__godot_wrapper_method)___get_wrapper_function(method_ptr);
^
./src/godot_fmod.cpp:47:5: note: in instantiation of function template specialization 'godot::register_method<float (godot::Fmod::)(unsigned long, const godot::Array &)>' requested here
register_method("get_event_parameter_by_id", &Fmod::get_event_parameter_by_id);
^
This is due to register_method not handling const references and instead returning a reference to a temporary stack variable.
This causes crashes on android on most API's as variants are not passed correctly.
Fixed and verified on android armv8