summaryrefslogtreecommitdiffstats
path: root/libbacktrace/BacktraceCurrent.cpp
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2015-05-14 15:39:52 -0700
committerChristopher Ferris <cferris@google.com>2015-05-14 17:56:41 -0700
commit30c942cf1024bf791c28ab9b67a1f752de72248c (patch)
tree3da915a8e19c5e1dd547614f3198bca217d7bf45 /libbacktrace/BacktraceCurrent.cpp
parent000c009bcc71bf8218d20c5575d3ae44c8bd4cda (diff)
downloadsystem_core-30c942cf1024bf791c28ab9b67a1f752de72248c.tar.gz
system_core-30c942cf1024bf791c28ab9b67a1f752de72248c.tar.bz2
system_core-30c942cf1024bf791c28ab9b67a1f752de72248c.zip
Prevent crashes if a map cannot be created.
Under some conditions, /proc/<pid>/maps might return nothing. If we try and unwind in this case, we'll crash. Check this case and fail the unwind. Add checks that no other functions try and use map_ without checking for nullptr. Add logging when an unwind fails so it's clear what happened. Bug: 21162746 Change-Id: I56ce51dda0cfc9db20475a441f118108196aa07c
Diffstat (limited to 'libbacktrace/BacktraceCurrent.cpp')
-rw-r--r--libbacktrace/BacktraceCurrent.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/libbacktrace/BacktraceCurrent.cpp b/libbacktrace/BacktraceCurrent.cpp
index 14f04de5e..95cd4d1a6 100644
--- a/libbacktrace/BacktraceCurrent.cpp
+++ b/libbacktrace/BacktraceCurrent.cpp
@@ -65,6 +65,11 @@ size_t BacktraceCurrent::Read(uintptr_t addr, uint8_t* buffer, size_t bytes) {
}
bool BacktraceCurrent::Unwind(size_t num_ignore_frames, ucontext_t* ucontext) {
+ if (GetMap() == nullptr) {
+ // Without a map object, we can't do anything.
+ return false;
+ }
+
if (ucontext) {
return UnwindFromContext(num_ignore_frames, ucontext);
}