Do not dump details of OOME for thread peer.
Test: testrunner.py --target --optimizing -t 004-ThreadStress
Bug: 154100060
Change-Id: I69582d7d1e4f5ced71ac32210ad7a0e4402da510
diff --git a/runtime/thread.cc b/runtime/thread.cc
index e4c55f2..6639501 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -1049,11 +1049,14 @@
self->CreatePeer(thread_name, as_daemon, thread_group);
if (self->IsExceptionPending()) {
// We cannot keep the exception around, as we're deleting self. Try to be helpful and log
- // it.
+ // the failure but do not dump the exception details. If we fail to allocate the peer, we
+ // usually also fail to allocate an exception object and throw a pre-allocated OOME without
+ // any useful information. If we do manage to allocate the exception object, the memory
+ // information in the message could have been collected too late and therefore misleading.
{
ScopedObjectAccess soa(self);
- LOG(ERROR) << "Exception creating thread peer:";
- LOG(ERROR) << self->GetException()->Dump();
+ LOG(ERROR) << "Exception creating thread peer: "
+ << ((thread_name != nullptr) ? thread_name : "<null>");
self->ClearException();
}
return false;
diff --git a/test/004-ThreadStress/check b/test/004-ThreadStress/check
index e351e13..f389e6b 100755
--- a/test/004-ThreadStress/check
+++ b/test/004-ThreadStress/check
@@ -26,5 +26,5 @@
# something we really need to worry about here.
sed '-es/[0-9][0-9]*/N/g' "$2" \
| diff --strip-trailing-cr -q "$1" - >/dev/null \
- && sed "/Exception creating thread peer:/,+3d" "$4" \
+ && grep -v "Exception creating thread peer:" "$4" \
| diff --strip-trailing-cr -q "$3" - >/dev/null