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

Unified Diff: src/global-handles.cc

Issue 3011009: Add a check that weak object handle is not in NEAR_DEATH state after weak callback invocation. (Closed)
Patch Set: Addressing Mads' comments Created 10 years, 5 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 | « include/v8.h ('k') | src/profile-generator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/global-handles.cc
diff --git a/src/global-handles.cc b/src/global-handles.cc
index e4bb925f0e9299ea105df757004d0912dad893b0..573669a4572b813c85bc613ebe176389d3da5886 100644
--- a/src/global-handles.cc
+++ b/src/global-handles.cc
@@ -151,13 +151,14 @@ class GlobalHandles::Node : public Malloced {
bool PostGarbageCollectionProcessing() {
if (state_ != Node::PENDING) return false;
LOG(HandleEvent("GlobalHandle::Processing", handle().location()));
+ WeakReferenceCallback func = callback();
+ if (func == NULL) {
+ Destroy();
+ return false;
+ }
void* par = parameter();
state_ = NEAR_DEATH;
set_parameter(NULL);
- // The callback function is resolved as late as possible to preserve old
- // behavior.
- WeakReferenceCallback func = callback();
- if (func == NULL) return false;
v8::Persistent<v8::Object> object = ToApi<v8::Object>(handle());
{
@@ -178,6 +179,9 @@ class GlobalHandles::Node : public Malloced {
VMState state(EXTERNAL);
func(object, par);
}
+ // Absense of explicit cleanup or revival of weak handle
+ // in most of the cases would lead to memory leak.
+ ASSERT(state_ != NEAR_DEATH);
return true;
}
« no previous file with comments | « include/v8.h ('k') | src/profile-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698