Repository navigation
Conversation
A P2P transport can be selected while the connection still owes its ConnectOK and has no derived keys, so SNP_SendPacket encrypts with a null context. Drop the packet instead, as DecryptDataChunk already does on receive.
A field crash dump shows a remotely initiated P2P connection selecting a transport and sending end-to-end stats while it still owed its ConnectOK and had no crypto keys, so SNP_SendPacket encrypted with a null send context. Stack: ThinkSelectTransport -> SelectTransport -> SendEndToEndStatsMsg -> SNP_SendPacket, preceded by BCryptKeysValid() asserts in SetRendezvousCommonFieldsAndSendSignal, right after the app closed and re-created the connection. We don't know yet how the connection gets into that state. For now, treat missing keys like a missing transport: assert and drop the packet, as DecryptDataChunk already does on receive. From PR #472.
|
Thanks, Bill! Merged as 6dd82fb, with a tweaked commit message. The guard is good defensive coding and we're happy to have it, but I don't think it's the whole story. m_eNegotiatedCipher is only ever set in FinishCryptoHandshake, in the same place the keys become valid, so the peer's crypt message can't set the cipher early. Your crash doesn't need that anyway: with the cipher still INVALID, SNP_SendPacket takes the encrypt branch and calls through the null context, which matches what you saw. So there's still a state bug somewhere that lets a remotely initiated connection be active, owe its ConnectOK, and have no keys. Your note that it happened right after the app closed and re-created the connection is probably the best lead. I'd love to take you up on the offer of the dump. If you can, please also send:
|
A field crash dump shows a remotely initiated P2P connection selecting a transport and sending end-to-end stats while it still owed its ConnectOK and had no crypto keys, so SNP_SendPacket encrypted with a null send context. Stack: ThinkSelectTransport -> SelectTransport -> SendEndToEndStatsMsg -> SNP_SendPacket, preceded by BCryptKeysValid() asserts in SetRendezvousCommonFieldsAndSendSignal, right after the app closed and re-created the connection. We don't know yet how the connection gets into that state. For now, treat missing keys like a missing transport: assert and drop the packet, as DecryptDataChunk already does on receive. From PR #472. (cherry picked from commit 6dd82fb)
A remotely initiated P2P connection can have its transport selected while it still owes its ConnectOK and has
not derived keys: the peer's crypt message has set
m_eNegotiatedCipher, butBFinishCryptoHandshakehas notrun, so
m_pCryptContextSendis null.SelectTransportthen sends an end-to-end stats packet throughSNP_SendPacket, which only assertsm_bCryptKeysValid(compiled out in release) and dereferences the nullcontext.
Field crash (release build, Windows 10): access violation at
SNP_SendPacket+0x26d,mov ecx,[this+0x16d4]; call [eax+4]with ecx = 0, right after two "Assertion Failed: BCryptKeysValid()" spews fromSetRendezvousCommonFieldsAndSendSignaland the application closing and re-creating that connection. Theminidump stack is the service thread: Think -> P2P ThinkConnection -> ThinkSelectTransport -> SelectTransport ->
SendEndToEndStatsMsg -> SNP_SendPacket. Happy to share the dump.
The fix treats missing keys like a missing transport: assert and drop the packet.
DecryptDataChunkalreadyguards the receive side the same way.