Search Unity

Crashes when one android lib calls into another android lib.

Discussion in 'Scripting' started by techmage, Jun 9, 2020.

  1. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,133
    So I have one android native C++ library, it works perfectly just by itself.

    But then I have a second android native C++ library, and it is trying to make C++ calls into the first android library.

    As soon I make a call to the second library and it loads, the whole thing crashes. I am not extremely knowledgeable about C++ linking especially on android. I assume this is some kind of linker issue? But I really have no idea. Has anyone tried to do this before? How did you get it to work?

    These two libs are also two separate .aar's, is that an issue by any means?

    The error that is giving me is htis:
    Code (CSharp):
    1. Error rtc # Fatal error in: ../../../../sdk/android/src/jni/jvm.cc, line 74
    2. Error rtc # last system error: 88
    3. Error rtc # Check failed: !g_jvm
    4. Error rtc # InitGlobalJniVariables!
    5.  
    From the error it looks like the second lib is calling the init code on the first lib. But the first lib is already loaded. Could it be the second lib is trying to re-load an already loaded lib?
     
    Last edited: Jun 9, 2020
  2. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,133
    Here is the full stacktrace:
    Code (CSharp):
    1. Error rtc # Fatal error in: ../../../../sdk/android/src/jni/jvm.cc, line 74
    2. Error rtc # last system error: 88
    3. Error rtc # Check failed: !g_jvm
    4. Error rtc # InitGlobalJniVariables!
    5. Error CRASH signal 6 (SIGABRT), code -6 (?), fault addr --------
    6. Error CRASH *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    7. Error CRASH Build type 'Development', Scripting Backend 'il2cpp', CPU 'arm64-v8a'
    8. Error CRASH Build fingerprint: 'oculus/vr_monterey/monterey:7.1.1/NGI77B/655140.17060.0:user/release-keys'
    9. Error CRASH Revision: '0'
    10. Error CRASH pid: 19546, tid: 19561, name: UnityMain  >>> com.DefaultCompany.NativeRenderTest <<<
    11. Error CRASH     x0   0000000000000000  x1   0000000000004c69  x2   0000000000000006  x3   0000000000000008
    12. Error CRASH     x4   0000007f77f8acf8  x5   0000000000000000  x6   0000000000008080  x7   68716055686d496b
    13. Error CRASH     x8   0000000000000083  x9   0000007f77f8f450  x10  14fa22bf9afcb60c  x11  14fa22bf9afcb60c
    14. Error CRASH     x12  0000000000000000  x13  0000000000000020  x14  ffffffffffffffdf  x15  0000000000000000
    15. Error CRASH     x16  0000007f79db4ec8  x17  0000007f79d55ed0  x18  000000000000ffff  x19  0000007f77f8f4f8
    16. Error CRASH     x20  0000000000000006  x21  0000007f77f8f450  x22  0000000000000058  x23  0000007f7966c400
    17. Error CRASH     x24  0000007f77f8b4ec  x25  0000007f55aa88c0  x26  0000000000000000  x27  0000007f549f283c
    18. Error CRASH     x28  0000007f795ec0d0  x29  0000007f77f8b0c0  x30  0000007f79d52c84
    19. Error CRASH     sp   0000007f77f8b0a0  pc   0000007f79d55ed8  pstate 0000000060000000
    20. Error CRASH
    21. Error CRASH backtrace:
    22. Error CRASH     #00  pc 00000000000004ec  [vdso] ()
    23. Error CRASH     #01  pc 0000000000079ed4  /system/lib64/libc.so (tgkill+4)
    24. Error CRASH     #02  pc 0000000000076c80  /system/lib64/libc.so (pthread_kill+64)
    25. Error CRASH     #03  pc 0000000000024ac0  /system/lib64/libc.so (raise+24)
    26. Error CRASH     #04  pc 000000000001cdcc  /system/lib64/libc.so (abort+52)
    27. Error CRASH     #05  pc 0000000000110dc4  /data/app/com.DefaultCompany.NativeRenderTest-1/lib/arm64/libmrwebrtc.so (_ZN3rtc18webrtc_checks_impl8FatalLogEPKciS2_PKNS0_12CheckArgTypeEz+440)
    28. Error CRASH     #06  pc 000000000055f400  /data/app/com.DefaultCompany.NativeRenderTest-1/lib/arm64/libmrwebrtc.so (_ZN6webrtc3jni22InitGlobalJniVariablesEP7_JavaVM+156)
    29. Error CRASH     #07  pc 00000000000d8870  /data/app/com.DefaultCompany.NativeRenderTest-1/lib/arm64/libmrwebrtc.so (JNI_OnLoad+52)
    30. Error CRASH     #08  pc 0000000000304a68  /system/lib64/libart.so (_ZN3art9JavaVMExt17LoadNativeLibraryEP7_JNIEnvRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEEP8_jobjectP8_jstringPS9_+2168)
    31. Error CRASH     #09  pc 0000000000004698  /system/lib64/libopenjdkjvm.so (JVM_NativeLoad+284)
    32. Error CRASH     #10  pc 0000000000090630  /system/framework/arm64/boot.oat ()
    33.  
     
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,736
    What does a C++ call site from one library to another even look like when those libraries are separate? I can't imagine. It would have to link before it could build. How would that look?

    Do you mean from the C# Unity side you call an entrypoint in a second library after calling something in the first? If so, can you call the second library without calling the first or does that crash as well?
     
    Joe-Censored likes this.