Fix for GetCurrentLocation when stack is empty.
GetCurrentLocation now returns a dummy value and line number when the
stack is empty. This prevents problems with logging during locking when
a thread tries to join, where its stack would be empty.
Change-Id: Ib49ac6fd86655bce579524bf7f165e95ae829d9a
diff --git a/src/thread.cc b/src/thread.cc
index e43aa14..2bdfb3c 100644
--- a/src/thread.cc
+++ b/src/thread.cc
@@ -1194,6 +1194,14 @@
void Thread::GetCurrentLocation(const char*& source_file, uint32_t& line_number) const {
Frame f = top_of_managed_stack_;
Method* m = f.GetMethod();
+
+ // Check if the stack is empty
+ if (m == NULL) {
+ source_file = "UNKNOWN";
+ line_number = 0;
+ return;
+ }
+
// TODO: can this ever happen?
if (m->IsCalleeSaveMethod()) {
f.Next();