From 333b9dd1677fc1656eed14f077e3b30a9fe4b540 Mon Sep 17 00:00:00 2001 From: Nick Banks Date: Wed, 15 Feb 2023 20:14:35 -0500 Subject: [PATCH] Improvements to Trackdown Stress Failures (#3437) --- .github/workflows/stress.yml | 3 +++ src/platform/platform_worker.c | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/.github/workflows/stress.yml b/.github/workflows/stress.yml index 735037d75..53e1164b9 100644 --- a/.github/workflows/stress.yml +++ b/.github/workflows/stress.yml @@ -30,10 +30,13 @@ jobs: xdp: ['', '-UseXdp'] sanitize: ['', '-Sanitize'] exclude: + # Schannel only supported on windows-2022 - os: ubuntu-20.04 tls: schannel - os: macos-12 tls: schannel + - os: windows-2019 + tls: schannel # Linux and Windows Schannel use ASAN - os: ubuntu-20.04 sanitize: '' diff --git a/src/platform/platform_worker.c b/src/platform/platform_worker.c index 585fe128a..fbe6d20d3 100644 --- a/src/platform/platform_worker.c +++ b/src/platform/platform_worker.c @@ -87,6 +87,10 @@ typedef struct QUIC_CACHEALIGN CXPLAT_WORKER { BOOLEAN InitializedECLock : 1; BOOLEAN StoppingThread : 1; BOOLEAN DestroyedThread : 1; +#if DEBUG // Debug flags - Must not be in the bitfield. + BOOLEAN ThreadStarted; + BOOLEAN ThreadFinished; +#endif // // Must not be bitfield. @@ -224,6 +228,10 @@ Error: NULL); CxPlatThreadWait(&CxPlatWorkers[i].Thread); CxPlatThreadDelete(&CxPlatWorkers[i].Thread); +#if DEBUG + CXPLAT_DBG_ASSERT(CxPlatWorkers[i].ThreadStarted); + CXPLAT_DBG_ASSERT(CxPlatWorkers[i].ThreadFinished); +#endif CxPlatWorkers[i].DestroyedThread = TRUE; } #ifdef CXPLAT_SQE_INIT @@ -270,6 +278,10 @@ CxPlatWorkersUninit( NULL); CxPlatThreadWait(&CxPlatWorkers[i].Thread); CxPlatThreadDelete(&CxPlatWorkers[i].Thread); +#if DEBUG + CXPLAT_DBG_ASSERT(CxPlatWorkers[i].ThreadStarted); + CXPLAT_DBG_ASSERT(CxPlatWorkers[i].ThreadFinished); +#endif CxPlatWorkers[i].DestroyedThread = TRUE; #ifdef CXPLAT_SQE_INIT CxPlatSqeCleanup(&CxPlatWorkers[i].EventQ, &CxPlatWorkers[i].UpdatePollSqe); @@ -436,6 +448,9 @@ CxPlatProcessEvents( State->NoWorkCount = 0; for (uint32_t i = 0; i < CqeCount; ++i) { if (CxPlatCqeUserData(&Cqes[i]) == NULL) { +#if DEBUG + CXPLAT_DBG_ASSERT(Worker->StoppingThread); +#endif return TRUE; // NULL user data means shutdown. } switch (CxPlatCqeType(&Cqes[i])) { @@ -468,6 +483,9 @@ CXPLAT_THREAD_CALLBACK(CxPlatWorkerThread, Context) PlatformWorkerThreadStart, "[ lib][%p] Worker start", Worker); +#if DEBUG + Worker->ThreadStarted = TRUE; +#endif CXPLAT_EXECUTION_STATE State = { 0, CxPlatTimeUs64(), UINT32_MAX, 0, CxPlatCurThreadID() }; @@ -501,6 +519,10 @@ Shutdown: Worker->Running = FALSE; +#if DEBUG + Worker->ThreadFinished = TRUE; +#endif + QuicTraceLogInfo( PlatformWorkerThreadStop, "[ lib][%p] Worker stop",