Index: src/unique.h |
diff --git a/src/unique.h b/src/unique.h |
index b56ee84a33695488d696aa89d3ea6e58361a0570..c04c966a4f9bc5f622c08c29d387039823e62c95 100644 |
--- a/src/unique.h |
+++ b/src/unique.h |
@@ -108,7 +108,12 @@ class Unique { |
} |
template <class S> static Unique<T> cast(Unique<S> that) { |
- return Unique<T>(that.raw_address_, Handle<T>::cast(that.handle_)); |
+ // Allow fetching location() to unsafe-cast the handle. This is necessary |
+ // since we can't concurrently safe-cast. Safe-casting requires looking at |
+ // the heap which may be moving concurrently to the compiler thread. |
+ AllowHandleDereference allow_deref; |
+ return Unique<T>(that.raw_address_, |
+ Handle<T>(reinterpret_cast<T**>(that.handle_.location()))); |
} |
inline bool IsInitialized() const { |