rvagg/nan — pull request #60 by bnoordhuis (2014-01-07 15:50:18+00:00)
Title: Fix unsafe persistent unwrapping

When creating a Local from a Persistent, don't assume that it is
safe to take the address of the Persistent and reinterpret_cast it
to Local when Persistent::IsWeak() == false. That logic works
*most* of the time but it breaks down badly when the storage cell is
freed and/or cleared. Contrived example:

Persistent persistent_handle;
NanAssignPersistent(Function, persistent_handle, /* ... */);
Local fun = NanPersistentToLocal(persistent_handle);
NanDispose(persistent_handle);
fun->Call(v8::Context::GetCurrent()->Global(), 0, NULL); // BAM!

Add a regression test to that effect. Most visible in debug builds,
it produces the following error message:

#
# Fatal error in ../deps/v8/src/handles-inl.h, line 69
# CHECK(location_ != __null && !(*location_)->IsFailure()) failed
#

On the subject of debug builds, a number of tests are failing hard in debug mode (but not persistent-test.js.)