godotengine / godot-cpp

C++ bindings for the Godot script API
MIT License
1.71k stars 573 forks source link

Crypto generate_random_bytes crashes #1152

Closed ashtonmeuser closed 1 year ago

ashtonmeuser commented 1 year ago

Godot version

3.5.2

godot-cpp version

3.x (7c09b5484de21c5be02ffee4fe32e27e9f4b7e14)

System information

macOS 13.4.1

Issue description

Calling Crypto().generate_random_bytes() causes the engine to crash. Project compiles as expected but crashes when run. The same works with Godot 4.x (godot-cpp 4.0.2 7fb46e9ea1571b1364ab049b2088e9b302ff7985).

No helpful error message besides the following.

================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v3.5.2.stable.official (170ba337a5d9e4c1e40d63b89dc1ba297b71860b)
Dumping the backtrace. Please include this when reporting the bug on: https://github.com/godotengine/godot/issues
-- END OF BACKTRACE --
================================================================

Steps to reproduce

  1. Create a GDNative C++ project
  2. Call Crypto().generate_random_bytes(1);
  3. Compile
  4. Run GDNative addon

Minimal reproduction project

N/A. Can use GDNative C++ example.

ashtonmeuser commented 1 year ago

Solved using the following for Godot 3.x.

Crypto::_new()->generate_random_bytes(n)

Differs just slightly from Godot 4.x syntax as follows.

Crypto().generate_random_bytes(n)