Freezes during stream init after switching to PSA API's #150

Open
opened 2026-08-22 17:12:28 -05:00 by trexx · 0 comments
trexx commented 2026-08-22 17:12:28 -05:00 (Migrated from github.com)

Sorry, I can see how my last comment was incorrect and useless. I'll try again.

I've provided a full backtrace here: https://gist.github.com/trexx/834fd4006067e2b1cbadda0cbc86aed8 and the blocked thread is 26.

blocked thread 26
  thread #26, name = 'Thread-9', stop reason = signal SIGSTOP
    frame #0: 0x0000002e5c630cf4 libc.so`read + 4
    frame #1: 0x0000002e5c63d268 libc.so`__sread + 48
    frame #2: 0x0000002e5c641560 libc.so`fread_unlocked + 248
    frame #3: 0x0000002e5c641428 libc.so`fread + 76
    frame #4: 0x0000003100b4a0b4 libmoonlight-core.so`mbedtls_platform_entropy_poll [inlined] fread(buf=0x00000031612483e8, (null)=18446744073709551615, size=1, count=128, stream=0x000000301d9224b8) at stdio.h:106:12
    frame #5: 0x0000003100b4a0a0 libmoonlight-core.so`mbedtls_platform_entropy_poll(data=<unavailable>, output="7K\xfb]h,\x9d*\xa9\xb5 $\xbd\xa8\xfd\th\xae\xf0\xfa\x95\xaa\x82.\x8d\xe1\U00000002<:K\xfe\xefu\xaf\U00000003eyվ\xe9\b\xfaB\xc9rN\xfe\U00000001kk\x91X\xdc\xf5\x95D\x8b\U0000001e-\x9f\xd7\xf1Se\xff\xb2F\x83Q\xdfn\xee˿\xfd\x80\xb4Z\U00000014E\xdau[K\xa3T\xe1\\\xde+\r>\U00000014\x922", len=128, olen=0x00000031612483e0) at entropy_poll.c:193:16
    frame #6: 0x0000003100b49bfc libmoonlight-core.so`entropy_gather_internal(ctx=0x0000003100b69e90) at entropy.c:219:20
    frame #7: 0x0000003100b49d10 libmoonlight-core.so`mbedtls_entropy_func(data=0x0000003100b69e90, output="", len=16) at entropy.c:308:20
    frame #8: 0x0000003100b48b08 libmoonlight-core.so`mbedtls_ctr_drbg_reseed_internal(ctx=0x0000003100b6a1f8, additional="PSA", len=3, nonce_len=16) at ctr_drbg.c:476:18
    frame #9: 0x0000003100b48c5c libmoonlight-core.so`mbedtls_ctr_drbg_seed(ctx=0x0000003100b6a1f8, f_entropy=(libmoonlight-core.so`mbedtls_entropy_func at entropy.c:271), p_entropy=0x0000003100b69e90, custom="PSA", len=3) at ctr_drbg.c:583:16
    frame #10: 0x0000003100b49790 libmoonlight-core.so`psa_random_internal_seed [inlined] mbedtls_psa_drbg_seed(drbg_ctx=<unavailable>, entropy=<unavailable>, custom="PSA", len=3) at psa_crypto_random_impl.h:136:12
    frame #11: 0x0000003100b49788 libmoonlight-core.so`psa_random_internal_seed(rng=0x0000003100b69e80) at psa_crypto_random.c:66:15
    frame #12: 0x0000003100b4492c libmoonlight-core.so`psa_crypto_init [inlined] mbedtls_psa_random_seed(rng=<unavailable>) at psa_crypto.c:8017:12
    frame #13: 0x0000003100b44928 libmoonlight-core.so`psa_crypto_init [inlined] mbedtls_psa_crypto_init_subsystem(subsystem=PSA_CRYPTO_SUBSYSTEM_RNG) at psa_crypto.c:8553:26
    frame #14: 0x0000003100b448b8 libmoonlight-core.so`psa_crypto_init at psa_crypto.c:8631:14
    frame #15: 0x0000003100b0f8d0 libmoonlight-core.so`PltEncryptMessage(ctx=0x0000002f4d972ba0, algorithm=<unavailable>, flags=<unavailable>, key="u\xe8$\xfem\U0000007f\xc4\xf1m\U00000001\xe0\xd8tH\xd5K\xea\U00000012\xf9\x88", keyLength=16, iv="\U00000001", ivLength=12, tag="", tagLength=16, inputData="OPTIONS rtspenc://192.168.0.12:48010 RTSP/1.0\r\nCSeq: 1\r\nX-GS-ClientVersion: 14\r\nHost: 192.168.0.12\r\n\r\n", inputDataLength=102, outputData="", outputDataLength=0x0000003161248ab0) at PlatformCrypto.c:60:17
    frame #16: 0x0000003100b14ef4 libmoonlight-core.so`transactRtspMessage [inlined] sealRtspMessage(request=<unavailable>, messageLen=0x0000003161248ab0) at RtspConnection.c:137:15
    frame #17: 0x0000003100b14e20 libmoonlight-core.so`transactRtspMessage [inlined] transactRtspMessageTcp(request=<unavailable>, response=0x0000003161248b48, error=0x0000003161248c10) at RtspConnection.c:428:25
    frame #18: 0x0000003100b14dc4 libmoonlight-core.so`transactRtspMessage(request=<unavailable>, response=0x0000003161248b48, expectingPayload=<unavailable>, error=0x0000003161248c10) at RtspConnection.c:530:16
    frame #19: 0x0000003100b13854 libmoonlight-core.so`performRtspHandshake [inlined] requestOptions(response=0x0000003161248b48, error=0x0000003161248c10) at RtspConnection.c:543:15
    frame #20: 0x0000003100b13820 libmoonlight-core.so`performRtspHandshake(serverInfo=0x0000003161248d98) at RtspConnection.c:1051:14
    frame #21: 0x0000003100b07e28 libmoonlight-core.so`LiStartConnection(serverInfo=0x0000003161248d98, streamConfig=0x0000003161248dc0, clCallbacks=0x0000003100b58cf8, drCallbacks=0x0000003100b58d60, arCallbacks=0x0000003100b58d90, renderContext=0x0000000000000000, drFlags=0, audioContext=0x0000000000000000, arFlags=0) at Connection.c:444:11
    frame #22: 0x0000003100b24af0 libmoonlight-core.so`Java_com_limelight_nvstream_jni_MoonBridge_startConnection(env=0x0000002f9d96f070, clazz=<unavailable>, address=0x0000003161248f00, appVersion=0x0000003161248f04, gfeVersion=<unavailable>, rtspSessionUrl=0x0000003161248f0c, serverCodecModeSupport=2032385, width=3840, height=2160, fps=60, bitrate=100000, packetSize=1392, streamingRemotely=0, audioConfiguration=197322, supportedVideoFormats=769, clientRefreshRateX100=6000, riAesKey=0x0000003161248f10, riAesIv=0x0000003161248f14, videoCapabilities=16777223, colorSpace=1, colorRange=1, encryptionFlags=-1) at callbacks.c:621:15
    frame #23: 0x00000030eda7ced8 libart.so`art_quick_generic_jni_trampoline + 152
    frame #24: 0x00000030eda737ec libart.so`art_quick_invoke_static_stub + 572
    frame #25: 0x00000030edae8a98 libart.so`art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*) + 232
    frame #26: 0x00000030edc58320 libart.so`art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*) + 380
    frame #27: 0x00000030edc4f70c libart.so`bool art::interpreter::DoCall<true, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*) + 700
    frame #28: 0x00000030edfc2a58 libart.so`MterpInvokeStaticRange + 416
    frame #29: 0x00000030eda6dc98 libart.so`mterp_op_invoke_static_range + 24
    frame #30: 0x00000030edfbe578 libart.so`MterpInvokeInterface + 1812
    frame #31: 0x00000030eda6da18 libart.so`mterp_op_invoke_interface + 24
    frame #32: 0x00000030edc45c48 libart.so`art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.10194798506748459250) + 272
    frame #33: 0x00000030edfab5a8 libart.so`artQuickToInterpreterBridge + 784
    frame #34: 0x00000030eda7cffc libart.so`art_quick_to_interpreter_bridge + 92
    frame #35: 0x00000030eda73568 libart.so`art_quick_invoke_stub + 552

It seems my Shield didn't have enough entropy in its pool and because the device is /dev/random, it'll will block. This seems to be the default for mbedtls and I am not sure whether it maybe worth changing the device to /dev/urandom instead.
This seems to be visible now because psa_crypto_init is called when initialising the RTSP stream and that'll seed a DRBG.

Sorry, I can see how my last comment was incorrect and useless. I'll try again. I've provided a full backtrace here: https://gist.github.com/trexx/834fd4006067e2b1cbadda0cbc86aed8 and the blocked thread is 26. <details> <summary>blocked thread 26</summary> ``` thread #26, name = 'Thread-9', stop reason = signal SIGSTOP frame #0: 0x0000002e5c630cf4 libc.so`read + 4 frame #1: 0x0000002e5c63d268 libc.so`__sread + 48 frame #2: 0x0000002e5c641560 libc.so`fread_unlocked + 248 frame #3: 0x0000002e5c641428 libc.so`fread + 76 frame #4: 0x0000003100b4a0b4 libmoonlight-core.so`mbedtls_platform_entropy_poll [inlined] fread(buf=0x00000031612483e8, (null)=18446744073709551615, size=1, count=128, stream=0x000000301d9224b8) at stdio.h:106:12 frame #5: 0x0000003100b4a0a0 libmoonlight-core.so`mbedtls_platform_entropy_poll(data=<unavailable>, output="7K\xfb]h,\x9d*\xa9\xb5 $\xbd\xa8\xfd\th\xae\xf0\xfa\x95\xaa\x82.\x8d\xe1\U00000002<:K\xfe\xefu\xaf\U00000003eyվ\xe9\b\xfaB\xc9rN\xfe\U00000001kk\x91X\xdc\xf5\x95D\x8b\U0000001e-\x9f\xd7\xf1Se\xff\xb2F\x83Q\xdfn\xee˿\xfd\x80\xb4Z\U00000014E\xdau[K\xa3T\xe1\\\xde+\r>\U00000014\x922", len=128, olen=0x00000031612483e0) at entropy_poll.c:193:16 frame #6: 0x0000003100b49bfc libmoonlight-core.so`entropy_gather_internal(ctx=0x0000003100b69e90) at entropy.c:219:20 frame #7: 0x0000003100b49d10 libmoonlight-core.so`mbedtls_entropy_func(data=0x0000003100b69e90, output="", len=16) at entropy.c:308:20 frame #8: 0x0000003100b48b08 libmoonlight-core.so`mbedtls_ctr_drbg_reseed_internal(ctx=0x0000003100b6a1f8, additional="PSA", len=3, nonce_len=16) at ctr_drbg.c:476:18 frame #9: 0x0000003100b48c5c libmoonlight-core.so`mbedtls_ctr_drbg_seed(ctx=0x0000003100b6a1f8, f_entropy=(libmoonlight-core.so`mbedtls_entropy_func at entropy.c:271), p_entropy=0x0000003100b69e90, custom="PSA", len=3) at ctr_drbg.c:583:16 frame #10: 0x0000003100b49790 libmoonlight-core.so`psa_random_internal_seed [inlined] mbedtls_psa_drbg_seed(drbg_ctx=<unavailable>, entropy=<unavailable>, custom="PSA", len=3) at psa_crypto_random_impl.h:136:12 frame #11: 0x0000003100b49788 libmoonlight-core.so`psa_random_internal_seed(rng=0x0000003100b69e80) at psa_crypto_random.c:66:15 frame #12: 0x0000003100b4492c libmoonlight-core.so`psa_crypto_init [inlined] mbedtls_psa_random_seed(rng=<unavailable>) at psa_crypto.c:8017:12 frame #13: 0x0000003100b44928 libmoonlight-core.so`psa_crypto_init [inlined] mbedtls_psa_crypto_init_subsystem(subsystem=PSA_CRYPTO_SUBSYSTEM_RNG) at psa_crypto.c:8553:26 frame #14: 0x0000003100b448b8 libmoonlight-core.so`psa_crypto_init at psa_crypto.c:8631:14 frame #15: 0x0000003100b0f8d0 libmoonlight-core.so`PltEncryptMessage(ctx=0x0000002f4d972ba0, algorithm=<unavailable>, flags=<unavailable>, key="u\xe8$\xfem\U0000007f\xc4\xf1m\U00000001\xe0\xd8tH\xd5K\xea\U00000012\xf9\x88", keyLength=16, iv="\U00000001", ivLength=12, tag="", tagLength=16, inputData="OPTIONS rtspenc://192.168.0.12:48010 RTSP/1.0\r\nCSeq: 1\r\nX-GS-ClientVersion: 14\r\nHost: 192.168.0.12\r\n\r\n", inputDataLength=102, outputData="", outputDataLength=0x0000003161248ab0) at PlatformCrypto.c:60:17 frame #16: 0x0000003100b14ef4 libmoonlight-core.so`transactRtspMessage [inlined] sealRtspMessage(request=<unavailable>, messageLen=0x0000003161248ab0) at RtspConnection.c:137:15 frame #17: 0x0000003100b14e20 libmoonlight-core.so`transactRtspMessage [inlined] transactRtspMessageTcp(request=<unavailable>, response=0x0000003161248b48, error=0x0000003161248c10) at RtspConnection.c:428:25 frame #18: 0x0000003100b14dc4 libmoonlight-core.so`transactRtspMessage(request=<unavailable>, response=0x0000003161248b48, expectingPayload=<unavailable>, error=0x0000003161248c10) at RtspConnection.c:530:16 frame #19: 0x0000003100b13854 libmoonlight-core.so`performRtspHandshake [inlined] requestOptions(response=0x0000003161248b48, error=0x0000003161248c10) at RtspConnection.c:543:15 frame #20: 0x0000003100b13820 libmoonlight-core.so`performRtspHandshake(serverInfo=0x0000003161248d98) at RtspConnection.c:1051:14 frame #21: 0x0000003100b07e28 libmoonlight-core.so`LiStartConnection(serverInfo=0x0000003161248d98, streamConfig=0x0000003161248dc0, clCallbacks=0x0000003100b58cf8, drCallbacks=0x0000003100b58d60, arCallbacks=0x0000003100b58d90, renderContext=0x0000000000000000, drFlags=0, audioContext=0x0000000000000000, arFlags=0) at Connection.c:444:11 frame #22: 0x0000003100b24af0 libmoonlight-core.so`Java_com_limelight_nvstream_jni_MoonBridge_startConnection(env=0x0000002f9d96f070, clazz=<unavailable>, address=0x0000003161248f00, appVersion=0x0000003161248f04, gfeVersion=<unavailable>, rtspSessionUrl=0x0000003161248f0c, serverCodecModeSupport=2032385, width=3840, height=2160, fps=60, bitrate=100000, packetSize=1392, streamingRemotely=0, audioConfiguration=197322, supportedVideoFormats=769, clientRefreshRateX100=6000, riAesKey=0x0000003161248f10, riAesIv=0x0000003161248f14, videoCapabilities=16777223, colorSpace=1, colorRange=1, encryptionFlags=-1) at callbacks.c:621:15 frame #23: 0x00000030eda7ced8 libart.so`art_quick_generic_jni_trampoline + 152 frame #24: 0x00000030eda737ec libart.so`art_quick_invoke_static_stub + 572 frame #25: 0x00000030edae8a98 libart.so`art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*) + 232 frame #26: 0x00000030edc58320 libart.so`art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*) + 380 frame #27: 0x00000030edc4f70c libart.so`bool art::interpreter::DoCall<true, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*) + 700 frame #28: 0x00000030edfc2a58 libart.so`MterpInvokeStaticRange + 416 frame #29: 0x00000030eda6dc98 libart.so`mterp_op_invoke_static_range + 24 frame #30: 0x00000030edfbe578 libart.so`MterpInvokeInterface + 1812 frame #31: 0x00000030eda6da18 libart.so`mterp_op_invoke_interface + 24 frame #32: 0x00000030edc45c48 libart.so`art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.10194798506748459250) + 272 frame #33: 0x00000030edfab5a8 libart.so`artQuickToInterpreterBridge + 784 frame #34: 0x00000030eda7cffc libart.so`art_quick_to_interpreter_bridge + 92 frame #35: 0x00000030eda73568 libart.so`art_quick_invoke_stub + 552 ``` </details> It seems my Shield didn't have enough entropy in its pool and because the device is /dev/random, it'll will block. This seems to be the default for mbedtls and I am not sure whether it maybe worth changing the device to /dev/urandom instead. This seems to be visible now because psa_crypto_init is called when initialising the RTSP stream and that'll seed a DRBG.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-moonlight-stream/moonlight-common-c#150
No description provided.