[vm/profiler] Fix native stack walker to properly skip PC = 0xFF..FF
Fixes flaky service/get_cpu_profile_timeline_rpc_test test failure on debug/simdbc64
(Error "../../runtime/vm/profiler_service.cc: 290: error: expected: start_ < end_".)
Fixes https://github.com/dart-lang/sdk/issues/31794
Possible fix for https://github.com/dart-lang/sdk/issues/28736
Change-Id: I0119830d966aa24713c8572e28e4fc67e6d0de49
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100920
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
diff --git a/runtime/observatory/tests/service/service_kernel.status b/runtime/observatory/tests/service/service_kernel.status
index 7012181..cea771c 100644
--- a/runtime/observatory/tests/service/service_kernel.status
+++ b/runtime/observatory/tests/service/service_kernel.status
@@ -77,7 +77,6 @@
[ $arch == simdbc64 && $compiler == dartk ]
eval_test: RuntimeError, Timeout # Issue #34736
evaluate_in_frame_rpc_test: RuntimeError, Timeout # Issue #34736
-get_cpu_profile_timeline_rpc_test: Pass, RuntimeError # http://dartbug.com/31794
[ $arch == simdbc64 && $compiler == dartk && $mode == debug ]
eval_test: Pass, Slow
diff --git a/runtime/vm/profiler.cc b/runtime/vm/profiler.cc
index 7eed0f3..ed05a74 100644
--- a/runtime/vm/profiler.cc
+++ b/runtime/vm/profiler.cc
@@ -791,7 +791,8 @@
return;
}
- if ((pc + 1) < pc) {
+ const uword pc_value = reinterpret_cast<uword>(pc);
+ if ((pc_value + 1) < pc_value) {
// It is not uncommon to encounter an invalid pc as we
// traverse a stack frame. Most of these we can tolerate. If
// the pc is so large that adding one to it will cause an
@@ -805,7 +806,7 @@
// Move the lower bound up.
lower_bound_ = reinterpret_cast<uword>(fp);
- if (!Append(reinterpret_cast<uword>(pc), reinterpret_cast<uword>(fp))) {
+ if (!Append(pc_value, reinterpret_cast<uword>(fp))) {
return;
}
}
diff --git a/runtime/vm/profiler_service.cc b/runtime/vm/profiler_service.cc
index a92e31e..44bd3c5 100644
--- a/runtime/vm/profiler_service.cc
+++ b/runtime/vm/profiler_service.cc
@@ -2231,6 +2231,7 @@
}
ASSERT(pc >= native_start);
+ ASSERT(pc < (pc + 1)); // Should not overflow.
profile_code = new ProfileCode(ProfileCode::kNativeCode, native_start,
pc + 1, 0, null_code_);
if (native_name != NULL) {