Skip to content

Commit fa88d15

Browse files
committed
Make sure UniquePtrs get destructed after MsQuicRegistration
We were failing one of the DataTests due to the Client/Server secrets getting destroyed before the underlying TLS structure was done with them. This was occuring because in QuicTestConnectAndPing, the test function returns before the openssl TLS layer had completing registering the server side application read key, which isn't needed for the reporting of an established connection. The function returned, cleaned the secrets buffer, after which the TLS layer tried to access them, and boom. Thanks to @guhetier, who noted that the destruction of the MsQuicRegistration forces shutdown of the connection, and blocks on its completion, so if we move the declaration of the UniquePtr buffers to before the allocation of said registration, the fact that C++ calls destructors in reverse order ensures that the Secrets memory remains valid until the connection is shut down.
1 parent 7c82ab4 commit fa88d15

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/test/lib/DataTest.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,9 @@ QuicTestConnectAndPing(
419419
}
420420
#endif
421421

422+
UniquePtr<QUIC_TLS_SECRETS[]> ClientSecrets;
423+
UniquePtr<QUIC_TLS_SECRETS[]> ServerSecrets;
424+
422425
MsQuicRegistration Registration(NULL, QUIC_EXECUTION_PROFILE_TYPE_MAX_THROUGHPUT, true);
423426
TEST_TRUE(Registration.IsValid());
424427

@@ -428,8 +431,6 @@ QuicTestConnectAndPing(
428431
//
429432
}
430433

431-
UniquePtr<QUIC_TLS_SECRETS[]> ClientSecrets;
432-
UniquePtr<QUIC_TLS_SECRETS[]> ServerSecrets;
433434
if (ClientZeroRtt && !ServerRejectZeroRtt) {
434435
ClientSecrets.reset(
435436
new(std::nothrow) QUIC_TLS_SECRETS[ConnectionCount]);

0 commit comments

Comments
 (0)