godot icon indicating copy to clipboard operation
godot copied to clipboard

MD5.Create() Method causes "BUG: Unreferenced static string to 0" on MetaQuest2

Open krisutofu opened this issue 11 months ago • 1 comments

Tested versions

  • Reproducible in 4.2.1.stable, 4.2.2.rc1, 4.2.2.rc2, 4.3-dev5 (Mono versions)
  • not tested below 4.2 due to different tooling/project setup for XR

System information

Garuda Linux #1 ZEN SMP PREEMPT_DYNAMIC Sat, 16 Mar 2024 17:15:23 +0000 - X11 - Vulkan (Mobile) - integrated Intel(R) Xe Graphics (TGL GT2) () - 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz (8 Threads)

Issue description

Executing MD5.Create() in a C#-Script causes one or multiple of the below errors to appear in the Android Logcat during remote debugging with Meta Quest 2 (Android export template) – depending on the code that was executed before:

USER ERROR: BUG: Unreferenced static string to 0: XRRuntimeVersion
   at: unref (core/string/string_name.cpp:127)
USER ERROR: BUG: Unreferenced static string to 0: XRRuntimeName
   at: unref (core/string/string_name.cpp:127)
USER ERROR: BUG: Unreferenced static string to 0: _compression
   at: unref (core/string/string_name.cpp:127)
USER ERROR: BUG: Unreferenced static string to 0: @export_enum
   at: unref (core/string/string_name.cpp:129)
USER ERROR: BUG: Unreferenced static string to 0: @export_node_path
   at: unref (core/string/string_name.cpp:129)
USER ERROR: BUG: Unreferenced static string to 0: @export_flags
   at: unref (core/string/string_name.cpp:129)
USER ERROR: BUG: Unreferenced static string to 0: @export_placeholder
   at: unref (core/string/string_name.cpp:129)
USER ERROR: BUG: Unreferenced static string to 0: @export
   at: unref (core/string/string_name.cpp:129)
USER ERROR: BUG: Unreferenced static string to 0: @export_multiline
   at: unref (core/string/string_name.cpp:129)
USER ERROR: BUG: Unreferenced static string to 0: @export_range
   at: unref (core/string/string_name.cpp:129)
USER ERROR: BUG: Unreferenced static string to 0: @warning_ignore
   at: unref (core/string/string_name.cpp:129)
USER ERROR: BUG: Unreferenced static string to 0: Variant
   at: unref (core/string/string_name.cpp:127)
USER ERROR: BUG: Unreferenced static string to 0: @export_group
   at: unref (core/string/string_name.cpp:129)
USER ERROR: BUG: Unreferenced static string to 0: ShaderCompilation
   at: unref (core/string/string_name.cpp:127)

Either, there is a bug in the implementation of MD5.Create() on Android which destroys references to static StringNames, a buffer overflow, or something else is off from the Godot side.

Target Framework net8.0 produces the same error.

This incident makes the app crash or terminate itself.

Steps to reproduce

Create a running XR project for Meta Quest 2. Generate a C# Script. Add var md5Hasher = System.Security.Cryptography.MD5.Create();.

Minimal reproduction project (MRP)

When opening the project, please add the Godot XR Vendors plugin and install the export template. (Meta Plugin needs to be enabled in the export settings after adding the plugin.) md5_bug_godot_4.2.1-stable.zip

krisutofu avatar Mar 24 '24 20:03 krisutofu

PS: this seems to be related to the HashAlgorithm class in general. I get the same problem with SHA1 and SHA256.

krisutofu avatar Mar 24 '24 21:03 krisutofu

  • C# Android exports don't support System.Security.Cryptography.
    • See https://github.com/godotengine/godot/issues/84559 for more information.
  • You should be able to pack libssl.so and libcrypto.so into the exported APK to resolve the issue.
  • There is also a draft PR that should fix this, but it's still a work in progress. You can wait for the PR to be merged or compile it yourself and see if it works for you.
    • https://github.com/godotengine/godot/pull/88803.
  • I'll close this issue to consolidate in the one I mentioned. Thanks for the report nonetheless!

raulsntos avatar Mar 25 '24 04:03 raulsntos