Crash associated with TransportAndroid::ValidateCertificateCallback

Native StackTrace:

Thread 0 (crashed)
0 libunity.so 0x0000006fe0155880 CrashReporting::Android::SignalHandler(int, siginfo*, void*)
1 libunity.so 0x0000006fe0520684 NativeRuntimeException::signal_handler(int, siginfo*, void*)
2 app_process64 0x0000006346515c4c <system symbols missing>
3 [vdso] 0x0000007086ceb694 <system symbols missing>
4 libunity.so 0x0000006fe07a1a24 CertificateHandlerScript::ValidateCertificate(unitytls_x509_ref)
5 libunity.so 0x0000006fe07a4bd8 TransportAndroid::ValidateCertificateCallback(void*, void*, long, void*)
6 base.odex 0x0000006fe34a7198 <system symbols missing>

I am using unity 2018.4.12f1, this kind of crash usually come with the following logs on android:

Error Dec 6, 2019, 05:23:54.870 65536 java.net.UnknownHostException: Unable to resolve host "cdp.cloud.unity3d.com": No address associated with hostname
Error Dec 6, 2019, 05:23:55.563 65578 java.net.UnknownHostException: Unable to resolve host "cdp.cloud.unity3d.com": No address associated with hostname
Error Dec 6, 2019, 05:24:06.565 0 java.net.ProtocolException: unexpected end of stream

Do you do any UnityWebRequest of your own?

Yes,I request asset bundle from web server and streaming assets with UnityWebRequestAssetBundle, and assess web API with UnityWebRequest, some times UnityWebRequestAssetBundle failed to request asset bundle from steaming assets but which can be recovered by retrying again. I make request with the following c# code:

var request = new UnityWebRequest(url, "POST") {
        certificateHandler = new AcceptAnyCertificateHandler()
};
var bodyRaw = Encoding.UTF8.GetBytes(content);
request.uploadHandler = new UploadHandlerRaw(bodyRaw);
request.downloadHandler = new DownloadHandlerBuffer();

request.SetRequestHeader("Content-Type", "application/json");
request.SendWebRequest();
class AcceptAnyCertificateHandler : CertificateHandler {
        protected override bool ValidateCertificate(byte[] certificateData) {
            return true;
        }
}

Can you report a bug for it?

OK, reported.

@Aurimas-Cernius Is there any way to avoid this crash?

Can you show a more complete code?
Are you sure you don’t destroy your UWR before the certificate callback is called?

Does “destroy UWR” means to call UnityWebRequest.Dispose? I don’t understand how to achieve “destroy UWR before the certificate callback is called”. I checked my code, found some UnityWebRequest instance does not disposed when request failed, but UnityWebRequest.Dispose is always called after a request is done.

Yes, you destroy UWR by disposing it.

@Aurimas-Cernius - Any updates on this. We’re seeing it frequently in our application

Crashed: Thread: SIGSEGV  0x0000000000000168
#00 pc 0x7e683c libunity.so (CertificateHandlerScript::ValidateCertificate(unitytls_x509_ref)) (BuildId: 52ddd525c54dcd50d0279568f8b467333d098579)
#01 pc 0x7e6838 libunity.so (CertificateHandlerScript::ValidateCertificate(unitytls_x509_ref)) (BuildId: 52ddd525c54dcd50d0279568f8b467333d098579)

This is coming on some devices when we’re trying to fetch game configuration file(.json) from CDN.

We’re seeing same crashes in editor when reloading domain and entering play mode. We’re also using custom certificate handler. Log:

  ERROR: SymGetSymFromAddr64, GetLastError: 'The specified module could not be found.' (Address: 0000021E896E1596)
  ERROR: SymGetModuleInfo64, GetLastError: 'A dynamic link library (DLL) initialization routine failed.' (Address: 0000021E896E1596)
0x0000021E896E1596 ((<unknown>)) (function-name not available)
0x0000021F7A37497C (Mono JIT Code) UnityEngine.Networking.CertificateHandler:ValidateCertificateNative (byte[])

=================================================================
   Native Crash Reporting
=================================================================
Got a UNKNOWN while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================

=================================================================
   Managed Stacktrace:
=================================================================
     at <unknown> <0xffffffff>
     at UnityEngine.Networking.CertificateHandler:ValidateCertificateNative <0x0008b>
     at ¨eN!:€H‚“# <0x0018d>
=================================================================
A crash has been intercepted by the crash handler. For call stack and other details, see the latest crash report generated in:

Crash dump contains following content from WinDbg:

FILE_IN_CAB:  crash.dmp

CONTEXT:  (.ecxr)
rax=00007ff8a3890000 rbx=0000000000000004 rcx=0000000000000001
rdx=0000000000000000 rsi=0000000000000000 rdi=0000000000000004
rip=00007ff94b31cf19 rsp=000000ecc09fced0 rbp=0000021f78a6b710
r8=0000000100000000  r9=0000000000000017 r10=00007ff8a3c1fe22
r11=08084ccc724b1c6c r12=0000000000000000 r13=0000021c0745d538
r14=000000000000022d r15=0000000000000001
iopl=0         nv up ei pl nz na po nc
cs=0033  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00000206
KERNELBASE!RaiseException+0x69:
00007ff9`4b31cf19 0f1f440000      nop     dword ptr [rax+rax]
Resetting default scope

EXCEPTION_RECORD:  (.exr -1)
ExceptionAddress: 00007ff94b31cf19 (KERNELBASE!RaiseException+0x0000000000000069)
   ExceptionCode: e0000001
  ExceptionFlags: 00000001
NumberParameters: 0

PROCESS_NAME:  Unity.exe

ERROR_CODE: (NTSTATUS) 0xe0000001 - <Unable to get error code text>

EXCEPTION_CODE_STR:  e0000001

STACK_TEXT:
000000ec`c09fced0 00007ff8`a390064c     : 00000000`00000001 00007ff8`a3fb8398 00007ff8`a3eeebdb 00007ff8`a3eeebdb : KERNELBASE!RaiseException+0x69
000000ec`c09fcfb0 00007ff8`a38ec4a2     : 00007ff8`a3f04cf0 0000021f`78a6b710 00000000`00000000 000000ec`c09fd538 : mono_2_0_bdwgc!mono_dl_fallback_unregister+0xf8c
000000ec`c09fd070 00007ff8`a38ec508     : 00000002`c09f0101 00000000`00000000 00000000`000005fe 00007ff6`0ce042fd : mono_2_0_bdwgc!BrotliEncoderVersion+0xe1e2
000000ec`c09fd4f0 00007ff8`a3a1473d     : 00000000`00001168 0000021e`8e7d94d0 00007ff8`a3f04cf0 00000000`00000000 : mono_2_0_bdwgc!BrotliEncoderVersion+0xe248
000000ec`c09fd520 00007ff8`a3a3ad6c     : 0000021e`8e7d94d0 00000000`00000000 00000000`00000000 0000021e`8e6b4080 : mono_2_0_bdwgc!mono_metadata_type_hash+0xa9d
000000ec`c09fd560 00007ff8`a3a3b050     : 0000021f`e8e4e040 0000021f`e8e4b050 00000000`0000009f 00000000`00000000 : mono_2_0_bdwgc!mono_debug_enabled+0x2cc
000000ec`c09fd5a0 00007ff8`a3d4ed6b     : 0000021f`e8e4e020 000000ec`c09fd630 0000021f`f5d938f0 00007ff8`a3a3aff0 : mono_2_0_bdwgc!mono_debug_enabled+0x5b0
000000ec`c09fd5d0 00007ff8`a3a3b235     : 0000021e`8e6b4080 000000ec`c09fda20 0000021c`0745d538 0000021e`8e7d94d0 : mono_2_0_bdwgc!mono_breakpoint_clean_code+0xe66b
000000ec`c09fd600 00007ff8`a3a3ba1c     : 0000021e`8e6b4080 00000221`201b3840 0000021c`0745d5c8 00000221`201b3840 : mono_2_0_bdwgc!mono_debug_enabled+0x795
000000ec`c09fd660 00007ff8`a3ab0f5a     : 00000221`201b3840 00000221`201b3840 00000221`201b3840 0000021c`0745d5c8 : mono_2_0_bdwgc!mono_g_hash_table_destroy+0x15c
000000ec`c09fd6a0 00007ff8`a3a4caee     : 000000ec`c09fda20 0000021e`c7606bb8 00000000`00000098 0000021c`0745d510 : mono_2_0_bdwgc!mono_type_get_object+0x40a
000000ec`c09fd6f0 00007ff8`a3b07249     : 00000000`00000000 0000021f`7a37d0f0 0000021f`7a37d0f0 000000ec`c09fda20 : mono_2_0_bdwgc!mono_class_vtable+0xc2e
000000ec`c09fd7f0 00007ff8`a3b0da7c     : 0000021f`7902ada0 0000021e`91182d20 00000000`00000000 00000000`000006ee : mono_2_0_bdwgc!mono_unity_class_has_failure+0xb6d9
000000ec`c09fd860 00007ff8`a3c0103f     : 00000000`00000000 000000ec`c09fd989 0000021f`7902ada0 0000021e`8eb546d0 : mono_2_0_bdwgc!mono_jit_set_domain+0x375c
000000ec`c09fd8d0 00007ff8`a3c01fb8     : 0000021f`f5ce6c68 0000021f`7a37497c 0000021f`f5ce6cd8 0000021f`f5ce6c68 : mono_2_0_bdwgc!mono_install_ftnptr_eh_callback+0x1d3f
000000ec`c09fd9e0 0000021e`896e1596     : 00000000`00000000 0000021f`7a37497c 000000ec`c09fddb0 0000021f`7a3748f0 : mono_2_0_bdwgc!mono_install_ftnptr_eh_callback+0x2cb8
000000ec`c09fdba0 00000000`00000000     : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : 0x0000021e`896e1596


SYMBOL_NAME:  mono_2_0_bdwgc+f8c

MODULE_NAME: mono_2_0_bdwgc

IMAGE_NAME:  mono-2.0-bdwgc.dll

STACK_COMMAND:  ~54s; .ecxr ; kb

FAILURE_BUCKET_ID:  APPLICATION_FAULT_e0000001_mono-2.0-bdwgc.dll!Unknown

OS_VERSION:  10.0.19041.1

BUILDLAB_STR:  vb_release

OSPLATFORM_TYPE:  x64

OSNAME:  Windows 10

FAILURE_ID_HASH:  {bd48fd1e-8507-97c0-dee9-728ff1c72d95}