Does Receiver Create FD but Doesn't Close it on Destroy?

Looks like something is using FD but doesn’t close it, and it’s not within my code.

I basically just tear down the receiver and even delete my client pointer on pause. If I lock and unclock screen a few times, the client will crash upon connection, saying “FORTIFY: FD_SET: file descriptor 1280 >= FD_SETSIZE 1024”.

--------- beginning of crash
07-11 11:47:04.223 10018 10126 F libc    : FORTIFY: FD_SET: file descriptor 1280 >= FD_SETSIZE 1024
07-11 11:47:04.223 10018 10126 F libc    : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 10126 (Thread-14), pid 10018 (nreal.testxraar)
07-11 11:47:04.237  9373  2679 V AF::Track: isReady(3522): consider track ready with 2020/2020, target was 2020)
07-11 11:47:04.238  9373  2679 D AFExtImpl: checkTrackBuffer1() track 0xb400007e783e1a00 get INFO from NEW, channelCount 2, pid 10018
07-11 11:47:04.238  9373  2679 D AFExtImpl: initFromProperty()  0xb400007e661d5340, sLogdumpEnable 1, sPcmdumpEnable 0, sAdSwitch 1, checkpop 1, checkzd 1
07-11 11:47:04.244  1739  3342 D VerificationCodeController: notifyIMELayoutChanged: 0  0
07-11 11:47:04.291 13019 13019 E DEBUG   : failed to readlink /proc/10126/fd/647: No such file or directory
07-11 11:47:04.291 13019 13019 E DEBUG   : failed to readlink /proc/10126/fd/666: No such file or directory
07-11 11:47:04.300  1129 12916 I QC2Comp : [hevcD_3345] Stats: Pending(0) i/p-done(0) Works: Q: 0/Done 0|Work-Rate: Q(0.0/s Avg=0.0/s) Done(0.000/s Avg=0.000/s)| Stream: 30.00fps 0.0Kbps
07-11 11:47:04.300  1129 12916 I QC2Comp : Mem-usage: 
07-11 11:47:04.300  1129 12916 I QC2Comp : Total Mem-usage: 0.000 MB
07-11 11:47:04.360  1129 12922 I QC2Comp : [hevcD_3346] Stats: Pending(0) i/p-done(0) Works: Q: 0/Done 0|Work-Rate: Q(0.0/s Avg=0.0/s) Done(0.000/s Avg=0.000/s)| Stream: 30.00fps 0.0Kbps
07-11 11:47:04.360  1129 12922 I QC2Comp : Mem-usage: 
07-11 11:47:04.360  1129 12922 I QC2Comp : Total Mem-usage: 0.000 MB
07-11 11:47:04.429  9373  2679 E AudioFlingerExtImpl: updateAudioDetectState pid : 10018, get null buffer
07-11 11:47:04.429  9373  2679 V AF::Track: getNextBuffer(3522): underrun,  framesReady(0) < framesDesired(1004), state: 6
07-11 11:47:04.457 13019 13019 I crash_dump64: obtaining output fd from tombstoned, type: kDebuggerdTombstoneProto
07-11 11:47:04.459   768   768 I tombstoned: received crash request for pid 10126
07-11 11:47:04.461 13019 13019 I crash_dump64: performing dump of process 10018 (target tid = 10126)
07-11 11:47:04.482 13019 13019 E DEBUG   : failed to read /proc/uptime: Permission denied
07-11 11:47:04.493 10018 10062 E NREAL   : [2022-07-11 11:47:04.492] [12247] [ERROR] [NRSDK] Generic Camera data_bytes error, should be = 615680, cur = 1139149
07-11 11:47:04.497  9373  2679 V AF::Track: updateTrackFrameInfo: latencyMs:50.271041 startUpMs:594.849531 localTime:1492871531694262 startTime:1492870768761398 localPosition:8068 startPosition:0
07-11 11:47:04.647  1739  3342 D VerificationCodeController: notifyIMELayoutChanged: 0  0
07-11 11:47:04.765 10018 10062 W NREAL   : [2022-07-11 11:47:04.764] [12247] [WARN] [NRSDK] Camera frequency is 27Hz < 28Hz, prev ts = 253829, curr ts = 254853
07-11 11:47:04.794  9661  9705 D OplusAtlas.OplusMessageHandler: handleMessage: Msg { when=-1ms what=0 target=com.oplus.atlas.OplusMessageHandler$MyHandler }
07-11 11:47:04.864 13019 13019 F DEBUG   : Process name is ai.nreal.testxraar, not key_process
07-11 11:47:04.864 13019 13019 F DEBUG   : keyProcess: 0
07-11 11:47:04.864 13019 13019 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
07-11 11:47:04.864 13019 13019 F DEBUG   : Build fingerprint: 'OnePlus/OnePlus9_CH/OnePlus9:12/RKQ1.211103.002/R.202204132334:user/release-keys'
07-11 11:47:04.864 13019 13019 F DEBUG   : Revision: '0'
07-11 11:47:04.864 13019 13019 F DEBUG   : ABI: 'arm64'
07-11 11:47:04.864 13019 13019 F DEBUG   : Timestamp: 2022-07-11 11:47:04.482566356+0800
07-11 11:47:04.864 13019 13019 F DEBUG   : Process uptime: 0s
07-11 11:47:04.864 13019 13019 F DEBUG   : Cmdline: ai.nreal.testxraar
07-11 11:47:04.864 13019 13019 F DEBUG   : pid: 10018, tid: 10126, name: Thread-14  >>> ai.nreal.testxraar <<<
07-11 11:47:04.864 13019 13019 F DEBUG   : uid: 10343
07-11 11:47:04.864 13019 13019 F DEBUG   : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
07-11 11:47:04.864 13019 13019 F DEBUG   : Abort message: 'FORTIFY: FD_SET: file descriptor 1280 >= FD_SETSIZE 1024'
07-11 11:47:04.864 13019 13019 F DEBUG   :     x0  0000000000000000  x1  000000000000278e  x2  0000000000000006  x3  0000007094cfc0c0
07-11 11:47:04.864 13019 13019 F DEBUG   :     x4  8080808080808080  x5  8080808080808080  x6  8080808080808080  x7  8080808080808080
07-11 11:47:04.864 13019 13019 F DEBUG   :     x8  00000000000000f0  x9  cec3166ccdf22bef  x10 0000000000000000  x11 ffffff80fffffbdf
07-11 11:47:04.864 13019 13019 F DEBUG   :     x12 0000000000000001  x13 00005d8628656c9a  x14 000cfeff6fb06053  x15 0000000000000008
07-11 11:47:04.864 13019 13019 F DEBUG   :     x16 00000071cc3e4bc0  x17 00000071cc3bf680  x18 00000070bc1c2f3d  x19 0000000000002722
07-11 11:47:04.864 13019 13019 F DEBUG   :     x20 000000000000278e  x21 00000000ffffffff  x22 0000007094cfe000  x23 b400006f8850d154
07-11 11:47:04.864 13019 13019 F DEBUG   :     x24 0000007094cfe000  x25 0000007094cfc808  x26 0000007094cfe000  x27 0000000000000001
07-11 11:47:04.864 13019 13019 F DEBUG   :     x28 0000007094cfc82c  x29 0000007094cfc140
07-11 11:47:04.864 13019 13019 F DEBUG   :     lr  00000071cc36f99c  sp  0000007094cfc0a0  pc  00000071cc36f9c8  pst 0000000000001000
07-11 11:47:04.864 13019 13019 F DEBUG   : backtrace:
07-11 11:47:04.864 13019 13019 F DEBUG   :       #00 pc 00000000000799c8  /apex/com.android.runtime/lib64/bionic/libc.so (abort+168) (BuildId: bbbdeb7c87c74f1491f92c6e605095b0)
07-11 11:47:04.864 13019 13019 F DEBUG   :       #01 pc 000000000007b910  /apex/com.android.runtime/lib64/bionic/libc.so (__fortify_fatal(char const*, ...)+128) (BuildId: bbbdeb7c87c74f1491f92c6e605095b0)
07-11 11:47:04.864 13019 13019 F DEBUG   :       #02 pc 00000000000a3f58  /apex/com.android.runtime/lib64/bionic/libc.so (__FD_SET_chk+128) (BuildId: bbbdeb7c87c74f1491f92c6e605095b0)
07-11 11:47:04.864 13019 13019 F DEBUG   :       #03 pc 00000000003fd24c  /data/app/~~S_OBHCF-Qf6pNACckDFU5Q==/ai.nreal.testxraar-nGrNo-2AKRXE92z7amabxA==/base.apk!libPoco.so (Poco::Net::SocketImpl::poll(Poco::Timespan const&, int)+504) (BuildId: a5953ebf2e6651169ba816843da3b5214e8adcd6)
07-11 11:47:04.864 13019 13019 F DEBUG   :       #04 pc 00000000003fb9b4  /data/app/~~S_OBHCF-Qf6pNACckDFU5Q==/ai.nreal.testxraar-nGrNo-2AKRXE92z7amabxA==/base.apk!libPoco.so (Poco::Net::SocketImpl::connect(Poco::Net::SocketAddress const&, Poco::Timespan const&)+236) (BuildId: a5953ebf2e6651169ba816843da3b5214e8adcd6)
07-11 11:47:04.864 13019 13019 F DEBUG   :       #05 pc 00000000003b74e8  /data/app/~~S_OBHCF-Qf6pNACckDFU5Q==/ai.nreal.testxraar-nGrNo-2AKRXE92z7amabxA==/base.apk!libPoco.so (Poco::Net::HTTPSession::connect(Poco::Net::SocketAddress const&)+24) (BuildId: a5953ebf2e6651169ba816843da3b5214e8adcd6)
07-11 11:47:04.864 13019 13019 F DEBUG   :       #06 pc 00000000003a6638  /data/app/~~S_OBHCF-Qf6pNACckDFU5Q==/ai.nreal.testxraar-nGrNo-2AKRXE92z7amabxA==/base.apk!libPoco.so (Poco::Net::HTTPClientSession::reconnect()+156) (BuildId: a5953ebf2e6651169ba816843da3b5214e8adcd6)
07-11 11:47:04.864 13019 13019 F DEBUG   :       #07 pc 00000000003a5cc8  /data/app/~~S_OBHCF-Qf6pNACckDFU5Q==/ai.nreal.testxraar-nGrNo-2AKRXE92z7amabxA==/base.apk!libPoco.so (Poco::Net::HTTPClientSession::sendRequest(Poco::Net::HTTPRequest&)+204) (BuildId: a5953ebf2e6651169ba816843da3b5214e8adcd6)
07-11 11:47:04.864 13019 13019 F DEBUG   :       #08 pc 0000000000339858  /data/app/~~S_OBHCF-Qf6pNACckDFU5Q==/ai.nreal.testxraar-nGrNo-2AKRXE92z7amabxA==/base.apk!libgrid.so (RtspSessionPocoBase::SendRequest(RTSPRequest&, long*, RTSPErrorCode&, int, RtspRequestState&, unsigned short&)+640) (BuildId: 928998c5fec6e4cadfc56cfc3564c147b997ad08)
07-11 11:47:04.864 13019 13019 F DEBUG   :       #09 pc 0000000000338dcc  /data/app/~~S_OBHCF-Qf6pNACckDFU5Q==/ai.nreal.testxraar-nGrNo-2AKRXE92z7amabxA==/base.apk!libgrid.so (RtspSessionPocoBase::Perform(long*, RTSPRequest&, unsigned short)+216) (BuildId: 928998c5fec6e4cadfc56cfc3564c147b997ad08)
07-11 11:47:04.864 13019 13019 F DEBUG   :       #10 pc 00000000003056b0  /data/app/~~S_OBHCF-Qf6pNACckDFU5Q==/ai.nreal.testxraar-nGrNo-2AKRXE92z7amabxA==/base.apk!libgrid.so (RtspSessionPoco::Play()+480) (BuildId: 928998c5fec6e4cadfc56cfc3564c147b997ad08)
07-11 11:47:04.864 13019 13019 F DEBUG   :       #11 pc 00000000001bc638  /data/app/~~S_OBHCF-Qf6pNACckDFU5Q==/ai.nreal.testxraar-nGrNo-2AKRXE92z7amabxA==/base.apk!libgrid.so (ClientSession::startStreamingWithRtsp()+460) (BuildId: 928998c5fec6e4cadfc56cfc3564c147b997ad08)
07-11 11:47:04.864 13019 13019 F DEBUG   :       #12 pc 000000000018cf5c  /data/app/~~S_OBHCF-Qf6pNACckDFU5Q==/ai.nreal.testxraar-nGrNo-2AKRXE92z7amabxA==/base.apk!libgrid.so (ClientLibraryWrapper::nvstControlStreaming(NvstStreamingCommand_t)+400) (BuildId: 928998c5fec6e4cadfc56cfc3564c147b997ad08)
07-11 11:47:04.864 13019 13019 F DEBUG   :       #13 pc 000000000016df50  /data/app/~~S_OBHCF-Qf6pNACckDFU5Q==/ai.nreal.testxraar-nGrNo-2AKRXE92z7amabxA==/base.apk!libgrid.so (BuildId: 928998c5fec6e4cadfc56cfc3564c147b997ad08)
07-11 11:47:04.864 13019 13019 F DEBUG   :       #14 pc 0000000000172524  /data/app/~~S_OBHCF-Qf6pNACckDFU5Q==/ai.nreal.testxraar-nGrNo-2AKRXE92z7amabxA==/base.apk!libgrid.so (RunSdkCommand(char const*, std::__ndk1::function<NvstResult_t (char const*)> const&)+60) (BuildId: 928998c5fec6e4cadfc56cfc3564c147b997ad08)
07-11 11:47:04.864 13019 13019 F DEBUG   :       #15 pc 0000000000168894  /data/app/~~S_OBHCF-Qf6pNACckDFU5Q==/ai.nreal.testxraar-nGrNo-2AKRXE92z7amabxA==/base.apk!libgrid.so (nvstControlStreaming+84) (BuildId: 928998c5fec6e4cadfc56cfc3564c147b997ad08)
07-11 11:47:04.864 13019 13019 F DEBUG   :       #16 pc 000000000001099c  /data/app/~~S_OBHCF-Qf6pNACckDFU5Q==/ai.nreal.testxraar-nGrNo-2AKRXE92z7amabxA==/base.apk!libCloudXRClient.so (BuildId: 073d0a27c1a66952e321cc2628e4408f403874f2)
07-11 11:47:04.864 13019 13019 F DEBUG   :       #17 pc 000000000002d610  /data/app/~~S_OBHCF-Qf6pNACckDFU5Q==/ai.nreal.testxraar-nGrNo-2AKRXE92z7amabxA==/base.apk!libCloudXRClient.so (BuildId: 073d0a27c1a66952e321cc2628e4408f403874f2)
07-11 11:47:04.864 13019 13019 F DEBUG   :       #18 pc 000000000002d3ec  /data/app/~~S_OBHCF-Qf6pNACckDFU5Q==/ai.nreal.testxraar-nGrNo-2AKRXE92z7amabxA==/base.apk!libCloudXRClient.so (BuildId: 073d0a27c1a66952e321cc2628e4408f403874f2)
07-11 11:47:04.864 13019 13019 F DEBUG   :       #19 pc 00000000001201ec  /data/app/~~S_OBHCF-Qf6pNACckDFU5Q==/ai.nreal.testxraar-nGrNo-2AKRXE92z7amabxA==/base.apk!libnr_cxr.so (CloudXRClientNR::CreateReceiver(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, int)+2176) (BuildId: 525f8d51eebdf9c2ae6d74713c54918027d322c3)
07-11 11:47:04.864 13019 13019 F DEBUG   :       #20 pc 00000000000d20d4  /data/app/~~S_OBHCF-Qf6pNACckDFU5Q==/ai.nreal.testxraar-nGrNo-2AKRXE92z7amabxA==/base.apk!libnr_cxr.so (majorActions()+604) (BuildId: 525f8d51eebdf9c2ae6d74713c54918027d322c3)
07-11 11:47:04.864 13019 13019 F DEBUG   :       #21 pc 00000000000d2a14  /data/app/~~S_OBHCF-Qf6pNACckDFU5Q==/ai.nreal.testxraar-nGrNo-2AKRXE92z7amabxA==/base.apk!libnr_cxr.so (render_thread_run()+704) (BuildId: 525f8d51eebdf9c2ae6d74713c54918027d322c3)
07-11 11:47:04.864 13019 13019 F DEBUG   :       #22 pc 00000000000d72b0  /data/app/~~S_OBHCF-Qf6pNACckDFU5Q==/ai.nreal.testxraar-nGrNo-2AKRXE92z7amabxA==/base.apk!libnr_cxr.so (BuildId: 525f8d51eebdf9c2ae6d74713c54918027d322c3)
07-11 11:47:04.864 13019 13019 F DEBUG   :       #23 pc 00000000000d7284  /data/app/~~S_OBHCF-Qf6pNACckDFU5Q==/ai.nreal.testxraar-nGrNo-2AKRXE92z7amabxA==/base.apk!libnr_cxr.so (BuildId: 525f8d51eebdf9c2ae6d74713c54918027d322c3)
07-11 11:47:04.864 13019 13019 F DEBUG   :       #24 pc 00000000000d7238  /data/app/~~S_OBHCF-Qf6pNACckDFU5Q==/ai.nreal.testxraar-nGrNo-2AKRXE92z7amabxA==/base.apk!libnr_cxr.so (std::__ndk1::__bind_return<void (*)(), std::__ndk1::tuple<>, std::__ndk1::tuple<>, __is_valid_bind_return<void (*)(), std::__ndk1::tuple<>, std::__ndk1::tuple<> >::value>::type std::__ndk1::__bind<void (*)()>::operator()<>()+52) (BuildId: 525f8d51eebdf9c2ae6d74713c54918027d322c3)
07-11 11:47:04.864 13019 13019 F DEBUG   :       #25 pc 00000000000d71b8  /data/app/~~S_OBHCF-Qf6pNACckDFU5Q==/ai.nreal.testxraar-nGrNo-2AKRXE92z7amabxA==/base.apk!libnr_cxr.so (BuildId: 525f8d51eebdf9c2ae6d74713c54918027d322c3)
07-11 11:47:04.864 13019 13019 F DEBUG   :       #26 pc 00000000000d7118  /data/app/~~S_OBHCF-Qf6pNACckDFU5Q==/ai.nreal.testxraar-nGrNo-2AKRXE92z7amabxA==/base.apk!libnr_cxr.so (BuildId: 525f8d51eebdf9c2ae6d74713c54918027d322c3)
07-11 11:47:04.864 13019 13019 F DEBUG   :       #27 pc 00000000000d6a64  /data/app/~~S_OBHCF-Qf6pNACckDFU5Q==/ai.nreal.testxraar-nGrNo-2AKRXE92z7amabxA==/base.apk!libnr_cxr.so (BuildId: 525f8d51eebdf9c2ae6d74713c54918027d322c3)
07-11 11:47:04.864 13019 13019 F DEBUG   :       #28 pc 00000000000deb44  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+264) (BuildId: bbbdeb7c87c74f1491f92c6e605095b0)
07-11 11:47:04.864 13019 13019 F DEBUG   :       #29 pc 000000000007b2fc  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+68) (BuildId: bbbdeb7c87c74f1491f92c6e605095b0)

I’ve never seen a crash like this before. Is the check failure always in Poco::Net::SocketImpl::poll()? I’d have to ping a number of people here to see if anyone has ideas what FD might be in use there. The only long-lived and growing files are the logs and traces and dumps of various forms – were you running any particular logging/capture?

Otherwise, it’s possible there’s some kind of bug in libpoco. I admittedly don’t know the library in any detail, so can only theorize.

Might be good to see your overall log files from the run, as well as a logcat -d dump to a text file (just because some system things are in logcat that aren’t in our logging).

Many thanks.

My colleague told me FD is some sort of a “file description”-ish stuff that I don’t really know.

The awkward part is that I’m running on Android 12 and I can’t write cxr logs to sdcard due to Android permission limit.

My logcat is possible but it needs to wait till I get a couple my things off my plates, and I prefer to send it via email. Should I send it to Willian, probably?