Skip to content

Commit 988d6c6

Browse files
committed
[MERGE #5296 @atulkatti] MSFT:15975576 Add asserts to help investigating JSHost fuzzing crashes where only the Recycler background thread is around.
Merge pull request #5296 from atulkatti:Bug15975576.ShutdownThreads.1
2 parents e12446b + 4236c2a commit 988d6c6

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/Common/Memory/Recycler.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ class JavascriptThreadService;
3030
struct RecyclerMemoryData;
3131
#endif
3232

33+
#if DBG
34+
class ThreadContext;
35+
#endif
36+
3337
namespace Memory
3438
{
3539
// NOTE: There is perf lab test infrastructure that takes a dependency on the events in this enumeration. Any modifications may cause
@@ -650,6 +654,10 @@ struct CollectionParam
650654
#if ENABLE_CONCURRENT_GC
651655
class RecyclerParallelThread
652656
{
657+
#if DBG
658+
friend class ThreadContext;
659+
#endif
660+
653661
public:
654662
typedef void (Recycler::* WorkFunc)();
655663

@@ -1914,7 +1922,9 @@ class Recycler
19141922
friend class HeapInfo;
19151923
friend class HeapInfoManager;
19161924
friend class LargeHeapBucket;
1917-
1925+
#if DBG
1926+
friend class ThreadContext;
1927+
#endif
19181928
template <typename TBlockType>
19191929
friend class HeapBucketT;
19201930
template <typename TBlockType>

lib/Runtime/Base/ThreadContext.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,12 @@ ThreadContext::~ThreadContext()
525525
#ifdef ENABLE_SCRIPT_DEBUGGING
526526
Assert(this->debugManager == nullptr);
527527
#endif
528+
529+
#if DBG && ENABLE_CONCURRENT_GC && defined(_WIN32)
530+
AssertMsg(recycler->concurrentThread == NULL, "Recycler background thread should have been shutdown before destroying Recycler.");
531+
AssertMsg((recycler->parallelThread1.concurrentThread == NULL) && (recycler->parallelThread2.concurrentThread == NULL), "Recycler parallelThread(s) should have been shutdown before destroying Recycler.");
532+
#endif
533+
528534
HeapDelete(recycler);
529535
}
530536

0 commit comments

Comments
 (0)