Search Issue Tracker

By Design

Votes

3

Found in

2018.2.0a1

2018.2.0f2

Issue ID

1061714

Regression

Yes

[Android] AndroidJavaObject().Call<string> crashes with Fatal signal 11(SIGSEGV)

Android

-

Steps to reproduce:
1. Open user attached project
2. Build & Run on Android device
3. Observe that a crash occurs when the app is started

Expected result: Fatal signal 11(SIGSEGV) crash should not occur when starting application

Reproduced in: 2018.3.0a5, 2018.2.0f2, 2018.2.0a1
Not reproduced in: 2018.1.9f1, 2017.4.7f1, 2017.2.3p1
Regression since: 2018.2.0a1

Tested devices:
Samsung Galaxy S9 (SM-G960F), 8.0.0, CPU: Exynos 9 Series 9810, GPU: Mali-G72
Sony Xperia Z2 (D6503), 6.0.1, CPU: Snapdragon 801 MSM8974PRO-AB, GPU: Adreno (TM) 330

  1. Yury-Habets

    Aug 02, 2018

    The issue here was with the user's project, hence the resolution "by design". Please submit another bug report with your project attached if you face any JNI issues.

    Thanks!

Comments (12)

  1. tarasfromlviv

    Sep 08, 2018 21:44

    This breaks a lot of code that was working before

  2. amjaliks

    Aug 03, 2018 09:38

    I've submitted similar report. You are welcome to vote, if you are affected.
    https://issuetracker.unity3d.com/issues/android-application-crashes-when-native-function-returns-null

  3. vzasadnyy_getsocial

    Aug 01, 2018 14:45

    Hey @UnityTeam could you please provide info why the ticket was closed and marked "By design"?
    How should we return "null" value from Java side if it keeps crashing?

    Thanks in advance.

  4. amjaliks

    Jul 26, 2018 12:16

    This issue still persists in 2018.2.1f1.

  5. AltimitSystems

    Jul 25, 2018 15:24

    This issue breaks many 3rd party Assets that were previously working. I've received emails related to Assets "crashing" and it turns out to be this issue.

    Surely this is not by design. Please reconsider and re-open this issue.

  6. seven_

    Jul 24, 2018 07:52

    Please fix this issue and remove this wrongly attached "by design" label!

    Workarounds might help for our own code, but not for all third-party libraries that access their native code... I will not really adjust them all.

  7. yurabereza

    Jul 24, 2018 07:16

    I have made such workaround, but gosh... i hope this will be fixed in Unity

    public static string safeCallStringMethod(AndroidJavaObject javaObject, string methodName, params object[] args)
    {
    #if UNITY_2018_2_OR_NEWER
    if (args == null) args = new object[] { null };
    IntPtr methodID = AndroidJNIHelper.GetMethodID<string>(javaObject.GetRawClass(), methodName, args, false);
    jvalue[] jniArgs = AndroidJNIHelper.CreateJNIArgArray(args);

    try
    {
    IntPtr returnValue = AndroidJNI.CallObjectMethod(javaObject.GetRawObject(), methodID, jniArgs);
    if (IntPtr.Zero != returnValue)
    {
    var val = AndroidJNI.GetStringUTFChars(returnValue);
    AndroidJNI.DeleteLocalRef(returnValue);
    return val;
    }
    }
    finally
    {
    AndroidJNIHelper.DeleteJNIArgArray(args, jniArgs);
    }

    return null;
    #else
    retun javaObject.Call<string>(methodName, args);
    #endif
    }

  8. yakswa

    Jul 24, 2018 06:42

    --java native code that--

    public class CrashTest {

    private static String testString = null;

    public static String GetTestStr() {
    return testString;
    }

    public static void SetTestStr(String str) {
    testString = str;
    }
    }

    pid: 19867, tid: 19893, name: UnityMain >>> com.test.MyApp <<<
    r0 00000000 r1 00000000 r2 b2693880 r3 00000000
    r4 e837e3a0 r5 00000000 r6 000033a2 r7 f30441a9
    r8 c93e3d28 r9 e837edf4 sl e837ed08 fp e837e4b0
    ip d3a0dcdc sp e837e348 lr d2943388 pc f49a3320 cpsr f625ec90
    at libc.strlen(strlen:11)
    at libunity.00122384(Native Method)

    my crash logcat message

    Is this by design?

  9. cat_muzzle

    Jul 23, 2018 09:16

    I have no workaround for this problem.

  10. amjaliks

    Jul 23, 2018 08:47

    Yes, more details, please! How some cryptic crash is part of this design?

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.