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

Unified Diff: runtime/vm/dart_api_impl.h

Issue 2640573003: Resolution for issue #5092: Unit test handle checks consider dangling handles to be valid. (Closed)
Patch Set: Created 3 years, 11 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
Index: runtime/vm/dart_api_impl.h
diff --git a/runtime/vm/dart_api_impl.h b/runtime/vm/dart_api_impl.h
index f597ca29d4e782aec56cab3c99d5d6b0654985c4..a1b8ded132a8038969b0663283ab75f141fca62b 100644
--- a/runtime/vm/dart_api_impl.h
+++ b/runtime/vm/dart_api_impl.h
@@ -9,6 +9,7 @@
#include "vm/native_arguments.h"
#include "vm/object.h"
#include "vm/safepoint.h"
+#include "vm/thread_registry.h"
namespace dart {
@@ -18,6 +19,7 @@ class FinalizablePersistentHandle;
class LocalHandle;
class PersistentHandle;
class ReusableObjectHandleScope;
+class ThreadRegistry;
const char* CanonicalFunction(const char* func);
@@ -166,6 +168,18 @@ class Api : AllStatic {
return (ClassId(handle) >= kInstanceCid);
}
+ // Returns true if the handle is non-dangling.
+ static bool IsValid(Dart_Handle handle) {
+ Isolate* isolate = Isolate::Current();
+ CHECK_ISOLATE(isolate);
+
+ // Check against all of the handles in the current isolate as well as the
+ // read-only handles.
+ return isolate->thread_registry()->IsValidHandle(handle) ||
bkonyi 2017/01/18 00:44:47 I'm not sure if I should be checking to see if any
Cutch 2017/01/18 14:49:51 In general our API always interacts with the curre
+ Dart::IsReadOnlyApiHandle(handle) ||
+ Dart::IsReadOnlyHandle(reinterpret_cast<uword>(handle));
+ }
+
// Returns true if the handle holds an Error.
static bool IsError(Dart_Handle handle) {
return RawObject::IsErrorClassId(ClassId(handle));

Powered by Google App Engine
This is Rietveld 408576698