Abort message: 'fdsan: attempted to close file descriptor 0, expected to be unowned

I’m working with CloudXR4.0

Abort message: 'fdsan: attempted to close file descriptor 0, expected to be unowned, actually owned by unique_fd 0x793a5e44bc'

It seems that the crash happen sometime with cxrGetConnectionStats。 It may occur with the call of cxrGetConnectionStats directly or cxrDestroyReceiver.

the backtrace list bellow:
call cxrGetConnectionStats directly:

e[31m07-09 14:10:18.168 27694 27694 F DEBUG   : Revision: '0'e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   : ABI: 'arm64'e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   : Timestamp: 2024-07-09 14:10:17.759042506+0800e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   : Process uptime: 41se[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   : Cmdline: com.sampler.teste[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   : pid: 26385, tid: 27685, name: Thread-7  >>> com.sampler.test <<<e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   : uid: 10134e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   : tagged_addr_ctrl: 0000000000000001 (PR_TAGGED_ADDR_ENABLE)e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   : Abort message: 'fdsan: attempted to close file descriptor 0, expected to be unowned, actually owned by unique_fd 0x793a5e44bc'e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   :     x0  0000000000000000  x1  0000000000006c25  x2  0000000000000006  x3  0000007785039ad0e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   :     x4  631f646b68651f64  x5  631f646b68651f64  x6  631f646b68651f64  x7  7f7f7f7f7f7f7f7fe[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   :     x8  00000000000000f0  x9  0e6440acad947a90  x10 00000077850391fc  x11 0000007c04a8b028e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   :     x12 0000007c04a8b020  x13 000000007fffffff  x14 0000000000c58eac  x15 000001c5c4ea343ae[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   :     x16 0000007bf1ee0d18  x17 0000007bf1ebc3b0  x18 0000007785039591  x19 0000000000006711e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   :     x20 0000000000006c25  x21 000000778503c000  x22 0000000000000003  x23 00000077850398c8e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   :     x24 0000007785039bc0  x25 0000007785039840  x26 0000007785039800  x27 ffffff80ffffffc8e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   :     x28 000000778503c000  x29 0000007785039b60e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   :     lr  0000007bf1e6de08  sp  0000007785039780  pc  0000007bf1e6de2c  pst 0000000000001000e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   : 24 total framese[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   : backtrace:e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   :       #00 pc 000000000005fe2c  /apex/com.android.runtime/lib64/bionic/libc.so (fdsan_error(char const*, ...)+564) (BuildId: 50118287324a156bc7be11d3d940c7be)e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   :       #01 pc 000000000005fb30  /apex/com.android.runtime/lib64/bionic/libc.so (android_fdsan_close_with_tag+920) (BuildId: 50118287324a156bc7be11d3d940c7be)e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   :       #02 pc 000000000006037c  /apex/com.android.runtime/lib64/bionic/libc.so (close+20) (BuildId: 50118287324a156bc7be11d3d940c7be)e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   :       #03 pc 00000000005bfea4  /data/app/~~2LbpISqS1afC1t6VdX6Epw==/com.sampler.test-Ak1WhkEMibsqRB5wqqxR_g==/base.apk!libgrid.so (offset 0x54dc000) (BuildId: a1fad643b147955368d7a1e7f19a1cd8551323bb)e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   :       #04 pc 00000000005c29a4  /data/app/~~2LbpISqS1afC1t6VdX6Epw==/com.sampler.test-Ak1WhkEMibsqRB5wqqxR_g==/base.apk!libgrid.so (offset 0x54dc000) (mem_deref+48) (BuildId: a1fad643b147955368d7a1e7f19a1cd8551323bb)e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   :       #05 pc 00000000005bfe10  /data/app/~~2LbpISqS1afC1t6VdX6Epw==/com.sampler.test-Ak1WhkEMibsqRB5wqqxR_g==/base.apk!libgrid.so (offset 0x54dc000) (re_alloc+84) (BuildId: a1fad643b147955368d7a1e7f19a1cd8551323bb)e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   :       #06 pc 00000000005c1090  /data/app/~~2LbpISqS1afC1t6VdX6Epw==/com.sampler.test-Ak1WhkEMibsqRB5wqqxR_g==/base.apk!libgrid.so (offset 0x54dc000) (re_thread_init+96) (BuildId: a1fad643b147955368d7a1e7f19a1cd8551323bb)e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   :       #07 pc 0000000000240314  /data/app/~~2LbpISqS1afC1t6VdX6Epw==/com.sampler.test-Ak1WhkEMibsqRB5wqqxR_g==/base.apk!libgrid.so (offset 0x54dc000) (NattHolePunch::NattHolePunch(NvSocketUdp&, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, unsigned char)+412) (BuildId: a1fad643b147955368d7a1e7f19a1cd8551323bb)e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   :       #08 pc 0000000000245c20  /data/app/~~2LbpISqS1afC1t6VdX6Epw==/com.sampler.test-Ak1WhkEMibsqRB5wqqxR_g==/base.apk!libgrid.so (offset 0x54dc000) (UdpRtpSource::UdpRtpSource(NvSocketUdp&&)+372) (BuildId: a1fad643b147955368d7a1e7f19a1cd8551323bb)e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   :       #09 pc 00000000002459b4  /data/app/~~2LbpISqS1afC1t6VdX6Epw==/com.sampler.test-Ak1WhkEMibsqRB5wqqxR_g==/base.apk!libgrid.so (offset 0x54dc000) (UdpRtpSourceCreate(NvSocketUdp&&)+32) (BuildId: a1fad643b147955368d7a1e7f19a1cd8551323bb)e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   :       #10 pc 00000000001e72c0  /data/app/~~2LbpISqS1afC1t6VdX6Epw==/com.sampler.test-Ak1WhkEMibsqRB5wqqxR_g==/base.apk!libgrid.so (offset 0x54dc000) (BuildId: a1fad643b147955368d7a1e7f19a1cd8551323bb)e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   :       #11 pc 00000000001eead0  /data/app/~~2LbpISqS1afC1t6VdX6Epw==/com.sampler.test-Ak1WhkEMibsqRB5wqqxR_g==/base.apk!libgrid.so (offset 0x54dc000) (BuildId: a1fad643b147955368d7a1e7f19a1cd8551323bb)e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   :       #12 pc 00000000001f3168  /data/app/~~2LbpISqS1afC1t6VdX6Epw==/com.sampler.test-Ak1WhkEMibsqRB5wqqxR_g==/base.apk!libgrid.so (offset 0x54dc000) (BuildId: a1fad643b147955368d7a1e7f19a1cd8551323bb)e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   :       #13 pc 00000000001da4b4  /data/app/~~2LbpISqS1afC1t6VdX6Epw==/com.sampler.test-Ak1WhkEMibsqRB5wqqxR_g==/base.apk!libgrid.so (offset 0x54dc000) (BuildId: a1fad643b147955368d7a1e7f19a1cd8551323bb)e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   :       #14 pc 00000000001beabc  /data/app/~~2LbpISqS1afC1t6VdX6Epw==/com.sampler.test-Ak1WhkEMibsqRB5wqqxR_g==/base.apk!libgrid.so (offset 0x54dc000) (BuildId: a1fad643b147955368d7a1e7f19a1cd8551323bb)e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   :       #15 pc 00000000001bf300  /data/app/~~2LbpISqS1afC1t6VdX6Epw==/com.sampler.test-Ak1WhkEMibsqRB5wqqxR_g==/base.apk!libgrid.so (offset 0x54dc000) (BuildId: a1fad643b147955368d7a1e7f19a1cd8551323bb)e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   :       #16 pc 0000000000184198  /data/app/~~2LbpISqS1afC1t6VdX6Epw==/com.sampler.test-Ak1WhkEMibsqRB5wqqxR_g==/base.apk!libgrid.so (offset 0x54dc000) (BuildId: a1fad643b147955368d7a1e7f19a1cd8551323bb)e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   :       #17 pc 0000000000188d6c  /data/app/~~2LbpISqS1afC1t6VdX6Epw==/com.sampler.test-Ak1WhkEMibsqRB5wqqxR_g==/base.apk!libgrid.so (offset 0x54dc000) (BuildId: a1fad643b147955368d7a1e7f19a1cd8551323bb)e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   :       #18 pc 000000000017f400  /data/app/~~2LbpISqS1afC1t6VdX6Epw==/com.sampler.test-Ak1WhkEMibsqRB5wqqxR_g==/base.apk!libgrid.so (offset 0x54dc000) (nvstConnectToServer+112) (BuildId: a1fad643b147955368d7a1e7f19a1cd8551323bb)e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   :       #19 pc 000000000000fc50  /data/app/~~2LbpISqS1afC1t6VdX6Epw==/com.sampler.test-Ak1WhkEMibsqRB5wqqxR_g==/base.apk!libCloudXRClient.so (offset 0x19f7000) (BuildId: 533118f900dcd83a42f010686fcb0aa69fc6397e)e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   :       #20 pc 000000000002dfbc  /data/app/~~2LbpISqS1afC1t6VdX6Epw==/com.sampler.test-Ak1WhkEMibsqRB5wqqxR_g==/base.apk!libCloudXRClient.so (offset 0x19f7000) (BuildId: 533118f900dcd83a42f010686fcb0aa69fc6397e)e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   :       #21 pc 0000000000030710  /data/app/~~2LbpISqS1afC1t6VdX6Epw==/com.sampler.test-Ak1WhkEMibsqRB5wqqxR_g==/base.apk!libCloudXRClient.so (offset 0x19f7000) (BuildId: 533118f900dcd83a42f010686fcb0aa69fc6397e)e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   :       #22 pc 00000000000c3644  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+208) (BuildId: 50118287324a156bc7be11d3d940c7be)e[0m
e[31m07-09 14:10:18.168 27694 27694 F DEBUG   :       #23 pc 000000000005cfa4  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+68) (BuildId: 50118287324a156bc7be11d3d940c7be)e[0m

Call with cxrDestroyReceiver:

[31m07-08 16:34:11.019 16532 16532 F DEBUG   : Revision: '0'[0m
[31m07-08 16:34:11.019 16532 16532 F DEBUG   : ABI: 'arm64'[0m
[31m07-08 16:34:11.019 16532 16532 F DEBUG   : Timestamp: 2024-07-08 16:34:10.638656710+0800[0m
[31m07-08 16:34:11.019 16532 16532 F DEBUG   : Process uptime: 106s[0m
[31m07-08 16:34:11.019 16532 16532 F DEBUG   : Cmdline: com.sampler.test[0m
[31m07-08 16:34:11.019 16532 16532 F DEBUG   : pid: 15797, tid: 15797, name: m.xreal.cloudxr  >>> com.sampler.test <<<[0m
[31m07-08 16:34:11.019 16532 16532 F DEBUG   : uid: 10134[0m
[31m07-08 16:34:11.019 16532 16532 F DEBUG   : tagged_addr_ctrl: 0000000000000001 (PR_TAGGED_ADDR_ENABLE)[0m
[31m07-08 16:34:11.019 16532 16532 F DEBUG   : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------[0m
[31m07-08 16:34:11.019 16532 16532 F DEBUG   : Abort message: 'fdsan: attempted to close file descriptor 0, expected to be unowned, actually owned by unique_fd 0x793a5e147c'[0m
[31m07-08 16:34:11.019 16532 16532 F DEBUG   :     x0  0000000000000000  x1  0000000000003db5  x2  0000000000000006  x3  0000007fe3375130[0m
[31m07-08 16:34:11.019 16532 16532 F DEBUG   :     x4  631f646b68651f64  x5  631f646b68651f64  x6  631f646b68651f64  x7  7f7f7f7f7f7f7f7f[0m
[31m07-08 16:34:11.019 16532 16532 F DEBUG   :     x8  00000000000000f0  x9  8940aaf6a0d0af8c  x10 0000007fe337485c  x11 0000007c04a8b028[0m
[31m07-08 16:34:11.019 16532 16532 F DEBUG   :     x12 0000007c04a8b020  x13 000000007fffffff  x14 000000000045a8f8  x15 0000006a1f636834[0m
[31m07-08 16:34:11.019 16532 16532 F DEBUG   :     x16 0000007bf1ee0d18  x17 0000007bf1ebc3b0  x18 000000000008c074  x19 0000000000003db5[0m
[31m07-08 16:34:11.019 16532 16532 F DEBUG   :     x20 0000000000003db5  x21 0000007c03913000  x22 0000000000000003  x23 0000007fe3374f28[0m
[31m07-08 16:34:11.019 16532 16532 F DEBUG   :     x24 0000007fe3375220  x25 0000007fe3374ea0  x26 0000007fe3374e60  x27 ffffff80ffffffc8[0m
[31m07-08 16:34:11.019 16532 16532 F DEBUG   :     x28 0000007fe3375640  x29 0000007fe33751c0[0m
[31m07-08 16:34:11.019 16532 16532 F DEBUG   :     lr  0000007bf1e6de08  sp  0000007fe3374de0  pc  0000007bf1e6de2c  pst 0000000000001000[0m
[31m07-08 16:34:11.019 16532 16532 F DEBUG   : 49 total frames[0m
[31m07-08 16:34:11.019 16532 16532 F DEBUG   : backtrace:[0m
[31m07-08 16:34:11.019 16532 16532 F DEBUG   :       #00 pc 000000000005fe2c  /apex/com.android.runtime/lib64/bionic/libc.so (fdsan_error(char const*, ...)+564) (BuildId: 50118287324a156bc7be11d3d940c7be)[0m
[31m07-08 16:34:11.019 16532 16532 F DEBUG   :       #01 pc 000000000005fb30  /apex/com.android.runtime/lib64/bionic/libc.so (android_fdsan_close_with_tag+920) (BuildId: 50118287324a156bc7be11d3d940c7be)[0m
[31m07-08 16:34:11.019 16532 16532 F DEBUG   :       #02 pc 000000000006037c  /apex/com.android.runtime/lib64/bionic/libc.so (close+20) (BuildId: 50118287324a156bc7be11d3d940c7be)[0m
[31m07-08 16:34:11.019 16532 16532 F DEBUG   :       #03 pc 0000000000193dbc  /data/app/~~Tst4412qrVZlrL9ceaYYLg==/com.sampler.test-PyQMoI6NQPIEY2tT0VC3ZQ==/base.apk!libgrid.so (offset 0x5d89000) (NvEventDestroy+36) (BuildId: a1fad643b147955368d7a1e7f19a1cd8551323bb)[0m
[31m07-08 16:34:11.019 16532 16532 F DEBUG   :       #04 pc 00000000001b1b54  /data/app/~~Tst4412qrVZlrL9ceaYYLg==/com.sampler.test-PyQMoI6NQPIEY2tT0VC3ZQ==/base.apk!libgrid.so (offset 0x5d89000) (BuildId: a1fad643b147955368d7a1e7f19a1cd8551323bb)[0m
[31m07-08 16:34:11.019 16532 16532 F DEBUG   :       #05 pc 00000000001e207c  /data/app/~~Tst4412qrVZlrL9ceaYYLg==/com.sampler.test-PyQMoI6NQPIEY2tT0VC3ZQ==/base.apk!libgrid.so (offset 0x5d89000) (BuildId: a1fad643b147955368d7a1e7f19a1cd8551323bb)[0m
[31m07-08 16:34:11.019 16532 16532 F DEBUG   :       #06 pc 00000000001d9ab8  /data/app/~~Tst4412qrVZlrL9ceaYYLg==/com.sampler.test-PyQMoI6NQPIEY2tT0VC3ZQ==/base.apk!libgrid.so (offset 0x5d89000) (BuildId: a1fad643b147955368d7a1e7f19a1cd8551323bb)[0m
[31m07-08 16:34:11.019 16532 16532 F DEBUG   :       #07 pc 00000000001bdb9c  /data/app/~~Tst4412qrVZlrL9ceaYYLg==/com.sampler.test-PyQMoI6NQPIEY2tT0VC3ZQ==/base.apk!libgrid.so (offset 0x5d89000) (BuildId: a1fad643b147955368d7a1e7f19a1cd8551323bb)[0m
[31m07-08 16:34:11.019 16532 16532 F DEBUG   :       #08 pc 00000000001827c8  /data/app/~~Tst4412qrVZlrL9ceaYYLg==/com.sampler.test-PyQMoI6NQPIEY2tT0VC3ZQ==/base.apk!libgrid.so (offset 0x5d89000) (BuildId: a1fad643b147955368d7a1e7f19a1cd8551323bb)[0m
[31m07-08 16:34:11.019 16532 16532 F DEBUG   :       #09 pc 0000000000188d6c  /data/app/~~Tst4412qrVZlrL9ceaYYLg==/com.sampler.test-PyQMoI6NQPIEY2tT0VC3ZQ==/base.apk!libgrid.so (offset 0x5d89000) (BuildId: a1fad643b147955368d7a1e7f19a1cd8551323bb)[0m
[31m07-08 16:34:11.019 16532 16532 F DEBUG   :       #10 pc 000000000017ef2c  /data/app/~~Tst4412qrVZlrL9ceaYYLg==/com.sampler.test-PyQMoI6NQPIEY2tT0VC3ZQ==/base.apk!libgrid.so (offset 0x5d89000) (nvstDestroyClient+76) (BuildId: a1fad643b147955368d7a1e7f19a1cd8551323bb)[0m
[31m07-08 16:34:11.019 16532 16532 F DEBUG   :       #11 pc 00000000000105cc  /data/app/~~Tst4412qrVZlrL9ceaYYLg==/com.sampler.test-PyQMoI6NQPIEY2tT0VC3ZQ==/base.apk!libCloudXRClient.so (offset 0x5db000) (BuildId: 533118f900dcd83a42f010686fcb0aa69fc6397e)[0m
[31m07-08 16:34:11.020 16532 16532 F DEBUG   :       #12 pc 000000000002eae0  /data/app/~~Tst4412qrVZlrL9ceaYYLg==/com.sampler.test-PyQMoI6NQPIEY2tT0VC3ZQ==/base.apk!libCloudXRClient.so (offset 0x5db000) (BuildId: 533118f900dcd83a42f010686fcb0aa69fc6397e)[0m
[31m07-08 16:34:11.020 16532 16532 F DEBUG   :       #13 pc 000000000002abe8  /data/app/~~Tst4412qrVZlrL9ceaYYLg==/com.sampler.test-PyQMoI6NQPIEY2tT0VC3ZQ==/base.apk!libCloudXRClient.so (offset 0x5db000) (cxrDestroyReceiver+64) (BuildId: 533118f900dcd83a42f010686fcb0aa69fc6397e)[0m

Oooph. I thought file descriptor 0 issues had been fixed in the CloudXR 4.0 release. I will need to investigate this on our end.