Revert^2 "Make sure all runtime threads are in the System thread group."
This reverts commit 9ca8b2bf46978e3a5698f8a27b48aa7eff3514df.
The test 2005 exposed an ABA race which could cause the test to
sometimes fail with CHECK failures or GC corruption.
Reason for revert: Fixed issue causing ABA race in PreObjectAlloc with
test.
Test: ./test.py --host --debug-gc
Bug: 146178357
Change-Id: If265f765e0c1e692755904b4c40bbc718d98f065
diff --git a/runtime/thread_pool.cc b/runtime/thread_pool.cc
index 365c097..2bca5a9 100644
--- a/runtime/thread_pool.cc
+++ b/runtime/thread_pool.cc
@@ -97,10 +97,17 @@
void* ThreadPoolWorker::Callback(void* arg) {
ThreadPoolWorker* worker = reinterpret_cast<ThreadPoolWorker*>(arg);
Runtime* runtime = Runtime::Current();
- CHECK(runtime->AttachCurrentThread(worker->name_.c_str(),
- true,
- nullptr,
- worker->thread_pool_->create_peers_));
+ CHECK(runtime->AttachCurrentThread(
+ worker->name_.c_str(),
+ true,
+ // Thread-groups are only tracked by the peer j.l.Thread objects. If we aren't creating peers
+ // we don't need to specify the thread group. We want to place these threads in the System
+ // thread group because that thread group is where important threads that debuggers and
+ // similar tools should not mess with are placed. As this is an internal-thread-pool we might
+ // rely on being able to (for example) wait for all threads to finish some task. If debuggers
+ // are suspending these threads that might not be possible.
+ worker->thread_pool_->create_peers_ ? runtime->GetSystemThreadGroup() : nullptr,
+ worker->thread_pool_->create_peers_));
worker->thread_ = Thread::Current();
// Mark thread pool workers as runtime-threads.
worker->thread_->SetIsRuntimeThread(true);