Skip to content

Android crashes when using some functions, e.g. Image::detect_alpha() #941

@DmitriySalnikov

Description

@DmitriySalnikov

My library crashes on Android on this line. This method is called from GDScript in _ready.

I didn't find any logic in this error, but I found the sequence of statements for which the crash occurs.
I changed the example this way:

diff --git a/test/src/example.cpp b/test/src/example.cpp
index 890319d..2bdd72a 100644
--- a/test/src/example.cpp
+++ b/test/src/example.cpp
@@ -25,7 +25,12 @@ int Example::test_static(int p_a, int p_b) {
 	return p_a + p_b;
 }
 
+#include <godot_cpp/classes/image.hpp>
 void Example::test_static2() {
+	Ref<Image> img; img.instantiate();
+	img->detect_alpha();
+	UtilityFunctions::print("detect_alpha");
+
 	UtilityFunctions::print("  void static");
 }

This example runs on WIndows without any problems for me (and also my library runs on Windows, Linux and macOS).

But on Android the application crashes with such logs starting from beta5 ( v4.0.beta5.official [89a33d28f] and 00db31c ):

11-29 22:39:14.122 26073 26149 I godot   : Constructor.
11-29 22:39:14.122 26073 26149 I godot   : Notification: 18
11-29 22:39:14.127 26073 26149 E godot   : USER WARNING: Icon not supported by this display server.
11-29 22:39:14.127 26073 26149 E godot   :    at: set_icon (servers/display_server.cpp:508)
11-29 22:39:14.127 26073 26149 I godot   : Notification: 31
11-29 22:39:14.127 26073 26149 I godot   : Notification: 32
11-29 22:39:14.127 26073 26149 I godot   : Notification: 45
11-29 22:39:14.127 26073 26149 I godot   : Notification: 10
11-29 22:39:14.129 26073 26149 I godot   : Notification: 27
11-29 22:39:14.129 26073 26149 I godot   : Notification: 13
11-29 22:39:14.129 26073 26149 I godot   : Signal bind
11-29 22:39:14.129 26214 26394 I SecurityComp10200302: SecureX509TrustManager: checkServerTrusted succeed ,root ca issuer is : CN=GlobalSign, O=GlobalSign, OU=GlobalSign Root CA - R3
11-29 22:39:14.129 26073 26149 I godot   :
11-29 22:39:14.129 26073 26149 I godot   : To string
11-29 22:39:14.129 26073 26149 I godot   :   Example -->  Example:[ GDExtension::Example <--> Instance ID:24041751642 ]
11-29 22:39:14.129 26073 26149 I godot   :   ExampleMin -->  ExampleMin:[Wrapped:0]
11-29 22:39:14.129 26073 26149 I godot   : Static method calls
11-29 22:39:14.129 26073 26149 I godot   :   static (109) 109
11-29 22:39:14.129 26073 26149 F libc    : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x7cffffffe8 in tid 26149 (VkThread), pid 26073 (siontestproject)
11-29 22:39:14.189 26565 26565 I crash_dump64: performing dump of process 26073 (target tid = 26149)
11-29 22:39:14.195 26565 26565 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
11-29 22:39:14.195 26565 26565 F DEBUG   : Build fingerprint: 'HONOR/HLK-AL00/HWHLK-H:10/HONORHLK-AL00/102.0.0.270C00:user/release-keys'
11-29 22:39:14.195 26565 26565 F DEBUG   : Revision: '0'
11-29 22:39:14.195 26565 26565 F DEBUG   : ABI: 'arm64'
11-29 22:39:14.197 26565 26565 F DEBUG   : SYSVMTYPE: Maple
11-29 22:39:14.197 26565 26565 F DEBUG   : APPVMTYPE: Art
11-29 22:39:14.200 26565 26565 F DEBUG   : Timestamp: 2022-11-29 22:39:14+0300
11-29 22:39:14.200 26565 26565 F DEBUG   : pid: 26073, tid: 26149, name: VkThread  >>> org.godotengine.gdextensiontestproject <<<
11-29 22:39:14.200 26565 26565 F DEBUG   : uid: 10585
11-29 22:39:14.200 26565 26565 F DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x7cffffffe8
11-29 22:39:14.200 26565 26565 F DEBUG   :     x0  0000007cffffffe8  x1  0000007d582ecec8  x2  0000007d55bfa2e0  x3  0000007d55bfa2ec
11-29 22:39:14.200 26565 26565 F DEBUG   :     x4  0000007d63bcc390  x5  0000000000020006  x6  0000007d55bfa150  x7  0000006800000070
11-29 22:39:14.200 26565 26565 F DEBUG   :     x8  0000007d583988e0  x9  711ac00f99a86c4f  x10 0000000000000000  x11 0000000000000000
11-29 22:39:14.200 26565 26565 F DEBUG   :     x12 0000007d68ae2748  x13 0000006500000064  x14 000000000000000f  x15 0000000000000002
11-29 22:39:14.200 26565 26565 F DEBUG   :     x16 0000007d58396920  x17 0000007d58324e4c  x18 0000007d54d5c000  x19 0000007d55bfa3c8
11-29 22:39:14.200 26565 26565 F DEBUG   :     x20 0000007d55bfa408  x21 0000007d5830addc  x22 0000000000000001  x23 0000000000000000
11-29 22:39:14.200 26565 26565 F DEBUG   :     x24 0000007d68a62928  x25 0000007d55bfa588  x26 0000000000000000  x27 0000007d2edbc430
11-29 22:39:14.200 26565 26565 F DEBUG   :     x28 0000007d55bfa4f8  x29 0000007d00000000
11-29 22:39:14.200 26565 26565 F DEBUG   :     sp  0000007d55bfa310  lr  0000007d5830ae10  pc  0000007d58324e54
11-29 22:39:14.200 26565 26565 F DEBUG   :
11-29 22:39:14.200 26565 26565 F DEBUG   : backtrace:
11-29 22:39:14.200 26565 26565 F DEBUG   :       #00 pc 000000000008ae54  /data/app/org.godotengine.gdextensiontestproject-iXcZTZ40z-Dn-fs2wPiCJQ==/lib/arm64/libgdexample.android.template_debug.arm64.so (godot::_err_print_index_error(char const*, char const*, int, long, long, char const*, char const*, godot::String const&, bool)+292)

In the beta4 version ( v4.0.beta4.official [e6751549c] and 727673a ), everything works as intended:

11-29 22:23:35.928 24476 24519 I godot   : Constructor.
11-29 22:23:35.928 24476 24519 I godot   : Notification: 18
11-29 22:23:35.933 24476 24519 E godot   : USER WARNING: Icon not supported by this display server.
11-29 22:23:35.933 24476 24519 E godot   :    at: set_icon (servers/display_server.cpp:515)
11-29 22:23:35.933 24476 24519 I godot   : Notification: 31
11-29 22:23:35.933 24476 24519 I godot   : Notification: 32
11-29 22:23:35.933 24476 24519 I godot   : Notification: 45
11-29 22:23:35.933 24476 24519 I godot   : Notification: 10
11-29 22:23:35.934 24476 24519 I godot   : Notification: 27
11-29 22:23:35.934 24476 24519 I godot   : Notification: 13
11-29 22:23:35.934 24476 24519 I godot   : Signal bind
11-29 22:23:35.934 24476 24519 I godot   :
11-29 22:23:35.934 24476 24519 I godot   : To string
11-29 22:23:35.934 24476 24519 I godot   :   Example -->  Example:[ GDExtension::Example <--> Instance ID:23890756688 ]
11-29 22:23:35.934 24476 24519 I godot   :   ExampleMin -->  ExampleMin:[Wrapped:0]
11-29 22:23:35.934 24476 24519 I godot   : Static method calls
11-29 22:23:35.934 24476 24519 I godot   :   static (109) 109
11-29 22:23:35.934 24476 24519 I godot   : detect_alpha
11-29 22:23:35.934 24476 24519 I godot   :   void static
11-29 22:23:35.934 24476 24519 I godot   : Property list
11-29 22:23:35.934 24476 24519 I godot   :   property value  (100, 200, 300)
11-29 22:23:35.934 24476 24519 I godot   : Instance method calls
11-29 22:23:35.934 24476 24519 I godot   :   Simple func called.
11-29 22:23:35.934 24476 24519 I godot   :   Simple const func called.
11-29 22:23:35.934 24476 24519 I godot   :   Return something called.
11-29 22:23:35.934 24476 24519 I godot   :   returned some string
11-29 22:23:35.934 24476 24519 I godot   :   Return something const called.
11-29 22:23:35.934 24476 24519 I godot   :   returned const root:<Window#23404217270>
11-29 22:23:35.934 24476 24519 I godot   : ExampleRef created.
11-29 22:23:35.934 24476 24519 I godot   :   returned ref [Wrapped:0]
11-29 22:23:35.934 24476 24519 I godot   : ExampleRef destroyed.
11-29 22:23:35.934 24476 24519 I godot   :   returned  (1.2, 3.4, 5.6, 7.8)
11-29 22:23:35.934 24476 24519 I godot   : VarArg method calls
11-29 22:23:35.934 24476 24519 I godot   : ExampleRef created.
11-29 22:23:35.934 24476 24519 I godot   : ExampleRef created.
11-29 22:23:35.934 24476 24519 I godot   :   Example ref checks called with value: -9223372012745915488, returning value: -9223372012729138091
11-29 22:23:35.934 24476 24519 I godot   :   sending ref:  -9223372012745915488 returned ref:  -9223372012729138091
11-29 22:23:35.934 24476 24519 I godot   :   Varargs (Variant return) called with 4 arguments
11-29 22:23:35.934 24476 24519 I godot   :   vararg args 4
11-29 22:23:35.934 24476 24519 I godot   :   Varargs (int return) called with 4 arguments
11-29 22:23:35.934 24476 24519 I godot   :   vararg_nv ret 42
11-29 22:23:35.934 24476 24519 I godot   :   Varargs (no return) called with 4 arguments
11-29 22:23:35.934 24476 24519 I godot   : Method calls with default values
11-29 22:23:35.934 24476 24519 I godot   :   defval (300) 300
11-29 22:23:35.934 24476 24519 I godot   :   defval (250) 250
11-29 22:23:35.934 24476 24519 I godot   :   defval (150) 150
11-29 22:23:35.934 24476 24519 I godot   : Array and Dictionary
11-29 22:23:35.934 24476 24519 I godot   :   test array [1, 2]
11-29 22:23:35.934 24476 24519 I godot   :   test tarray [(1, 2), (2, 3)]
11-29 22:23:35.935 24476 24519 I godot   :   test dictionary { "hello": "world", "foo": "bar" }
11-29 22:23:35.935 24476 24519 I godot   : 1
11-29 22:23:35.935 24476 24519 I godot   : 2
11-29 22:23:35.935 24476 24519 I godot   : 3
11-29 22:23:35.935 24476 24519 I godot   : Properties
11-29 22:23:35.935 24476 24519 I godot   :   custom position is (0, 0)
11-29 22:23:35.935 24476 24519 I godot   :   custom position now is (50, 50)
11-29 22:23:35.935 24476 24519 I godot   : Constnts
11-29 22:23:35.935 24476 24519 I godot   :   FIRST 0
11-29 22:23:35.935 24476 24519 I godot   :   ANSWER_TO_EVERYTHING 42
11-29 22:23:35.935 24476 24519 I godot   :   CONSTANT_WITHOUT_ENUM 314
11-29 22:23:35.935 24476 24519 I godot   : ExampleRef destroyed.
11-29 22:23:35.935 24476 24519 I godot   : Notification: 2000
11-29 22:23:35.935 24476 24519 I godot   : Notification: 30

Also, I just checked my library on the beta4 version and it works as intended.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis has been identified as a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions