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

Unified Diff: test/cctest/test-api.cc

Issue 173060: Do not allow GlobalHandles::Create to reuse destoryed nodes (ones from free l... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 4 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
« src/global-handles.cc ('K') | « src/global-handles.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-api.cc
===================================================================
--- test/cctest/test-api.cc (revision 2717)
+++ test/cctest/test-api.cc (working copy)
@@ -6217,6 +6217,35 @@
}
+v8::Persistent<v8::Object> some_object;
+v8::Persistent<v8::Object> bad_handle;
+
+void NewPersistentHandleCallback(v8::Persistent<v8::Value>, void*) {
+ v8::HandleScope scope;
+ bad_handle = v8::Persistent<v8::Object>::New(some_object);
+}
+
+
+THREADED_TEST(NewPersistentHandleFromWeakCallback) {
+ LocalContext context;
+
+ v8::Persistent<v8::Object> handle1, handle2;
+ {
+ v8::HandleScope scope;
+ some_object = v8::Persistent<v8::Object>::New(v8::Object::New());
+ handle1 = v8::Persistent<v8::Object>::New(v8::Object::New());
+ handle2 = v8::Persistent<v8::Object>::New(v8::Object::New());
+ }
+ // Note: order is implementation dependent alas: currently
+ // global handle nodes are processed by PostGarbageCollectionProcessing
+ // in reverse allocation order, so if second allocated handle is deleted,
+ // weak callback of the first handle would be able to 'reallocate' it.
+ handle1.MakeWeak(NULL, NewPersistentHandleCallback);
+ handle2.Dispose();
+ i::Heap::CollectAllGarbage();
+}
+
+
THREADED_TEST(CheckForCrossContextObjectLiterals) {
v8::V8::Initialize();
« src/global-handles.cc ('K') | « src/global-handles.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698