Bug 805797 - Validate sp before unwinding to fix crash in mozilla::FramePointerStackWalk. r=ehsan
authorBenoit Girard <b56girard@gmail.com>
Wed, 21 Nov 2012 16:24:39 -0500
changeset 113934 716416590fb1de6dd801a6dbdfbc19971018ddfc
parent 113933 030c89e22e3ec525338a3afdbd0f119195779fa3
child 113935 4894a33a8ec3b8179ce68c637f9a14bbd61996a8
push id18460
push userb56girard@gmail.com
push dateWed, 21 Nov 2012 21:28:02 +0000
treeherdermozilla-inbound@4894a33a8ec3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs805797
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 805797 - Validate sp before unwinding to fix crash in mozilla::FramePointerStackWalk. r=ehsan
tools/profiler/TableTicker.cpp
--- a/tools/profiler/TableTicker.cpp
+++ b/tools/profiler/TableTicker.cpp
@@ -795,17 +795,19 @@ void TableTicker::doBacktrace(ThreadProf
   // Start with the current function.
   StackWalkCallback(aSample->pc, aSample->sp, &array);
 
 #ifdef XP_MACOSX
   pthread_t pt = GetProfiledThread(platform_data());
   void *stackEnd = reinterpret_cast<void*>(-1);
   if (pt)
     stackEnd = static_cast<char*>(pthread_get_stackaddr_np(pt));
-  nsresult rv = FramePointerStackWalk(StackWalkCallback, 0, &array, reinterpret_cast<void**>(aSample->fp), stackEnd);
+  nsresult rv = NS_OK;
+  if (aSample->fp >= aSample->sp && aSample->fp <= stackEnd)
+    rv = FramePointerStackWalk(StackWalkCallback, 0, &array, reinterpret_cast<void**>(aSample->fp), stackEnd);
 #else
   nsresult rv = NS_StackWalk(StackWalkCallback, 0, &array, thread);
 #endif
   if (NS_SUCCEEDED(rv)) {
     aProfile.addTag(ProfileEntry('s', "(root)"));
 
     ProfileStack* stack = aProfile.GetStack();
     int pseudoStackPos = 0;