Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(496)

Unified Diff: runtime/vm/debugger.cc

Issue 9726017: Fix use-after-free bug in debugger (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/debugger.cc
===================================================================
--- runtime/vm/debugger.cc (revision 5651)
+++ runtime/vm/debugger.cc (working copy)
@@ -317,12 +317,23 @@
pc_ = desc.PC(pc_desc_index);
ASSERT(pc_ != 0);
breakpoint_kind_ = desc.DescriptorKind(pc_desc_index);
+ ASSERT((breakpoint_kind_ == PcDescriptors::kIcCall) ||
+ (breakpoint_kind_ == PcDescriptors::kFuncCall) ||
+ (breakpoint_kind_ == PcDescriptors::kReturn));
}
CodeBreakpoint::~CodeBreakpoint() {
// Make sure we don't leave patched code behind.
ASSERT(!IsEnabled());
+ // Poison the data so we catch use after free errors.
+#ifdef DEBUG
+ function_ = Function::null();
+ pc_ = 0ul;
+ src_bpt_ = NULL;
+ next_ = NULL;
+ breakpoint_kind_ = PcDescriptors::kOther;
+#endif
}
@@ -880,17 +891,17 @@
if (stack_trace->Length() > 1) {
ActivationFrame* caller = stack_trace->ActivationFrameAt(1);
func = caller->DartFunction().raw();
- RemoveInternalBreakpoints();
}
}
+ RemoveInternalBreakpoints(); // *bpt is now invalid.
InstrumentForStepping(func);
} else if (resume_action_ == kStepInto) {
- RemoveInternalBreakpoints();
if (bpt->breakpoint_kind_ == PcDescriptors::kIcCall) {
int num_args, num_named_args;
uword target;
CodePatcher::GetInstanceCallAt(bpt->pc_, NULL,
&num_args, &num_named_args, &target);
+ RemoveInternalBreakpoints(); // *bpt is now invalid.
ActivationFrame* top_frame = stack_trace->ActivationFrameAt(0);
Instance& receiver = Instance::Handle(
top_frame->GetInstanceCallReceiver(num_args));
@@ -904,9 +915,11 @@
Function& callee = Function::Handle();
uword target;
CodePatcher::GetStaticCallAt(bpt->pc_, &callee, &target);
+ RemoveInternalBreakpoints(); // *bpt is now invalid.
InstrumentForStepping(callee);
} else {
ASSERT(bpt->breakpoint_kind_ == PcDescriptors::kReturn);
+ RemoveInternalBreakpoints(); // *bpt is now invalid.
// Treat like stepping out to caller.
if (stack_trace->Length() > 1) {
ActivationFrame* caller = stack_trace->ActivationFrameAt(1);
@@ -915,8 +928,8 @@
}
} else {
ASSERT(resume_action_ == kStepOut);
+ RemoveInternalBreakpoints(); // *bpt is now invalid.
// Set stepping breakpoints in the caller.
- RemoveInternalBreakpoints();
if (stack_trace->Length() > 1) {
ActivationFrame* caller = stack_trace->ActivationFrameAt(1);
InstrumentForStepping(caller->DartFunction());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698