fixup! fixup! [K/N][New MM] Disallow getting thread data for detached threads
This commit is contained in:
@@ -3739,7 +3739,6 @@ ALWAYS_INLINE void kotlin::AssertThreadState(MemoryState* thread, std::initializ
|
||||
}
|
||||
|
||||
MemoryState* kotlin::mm::GetMemoryState() noexcept {
|
||||
RuntimeAssert(memoryState != nullptr, "Thread is not attached to the runtime");
|
||||
return ::memoryState;
|
||||
}
|
||||
|
||||
|
||||
@@ -389,7 +389,8 @@ namespace kotlin {
|
||||
namespace mm {
|
||||
|
||||
// Returns the MemoryState for the current thread.
|
||||
// The current thread must be attached to the runtime.
|
||||
// For the new MM, the current thread must be attached to the runtime.
|
||||
// For the legacy MM, returns nullptr if called on a thread that is not attached to the runtime.
|
||||
// Try not to use it very often, as (1) thread local access can be slow on some platforms,
|
||||
// (2) TLS gets deallocated before our thread destruction hooks run.
|
||||
MemoryState* GetMemoryState() noexcept;
|
||||
|
||||
@@ -12,7 +12,11 @@
|
||||
using namespace kotlin;
|
||||
|
||||
TEST(MemoryStateTestDeathTest, GetMemoryStateForUnregisteredThread) {
|
||||
EXPECT_DEATH(mm::GetMemoryState(), "Thread is not attached to the runtime");
|
||||
if (CurrentMemoryModel == MemoryModel::kExperimental) {
|
||||
EXPECT_DEATH(mm::GetMemoryState(), "Thread is not attached to the runtime");
|
||||
} else {
|
||||
EXPECT_EQ(mm::GetMemoryState(), nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(MemoryStateTest, GetMemoryStateForRegisteredThread) {
|
||||
|
||||
Reference in New Issue
Block a user