You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think the problem is that WeakTag's constructor only checks IsObject(); ObjectInfo::Unwrap() then does a static_cast that returns a non-null WeakTag* mis-typed as ObjectInfo*, so the info_ == nullptr guard passes. The destructor of WeakTag later dereferences it in OnFree().
Thanks for the detailed report and root-cause analysis.
ObjectInfo::Unwrap() is inherited from Napi::ObjectWrap<T>::Unwrap, which is just napi_unwrap + static_cast<T*> with no check that the object was actually constructed as an ObjectInfo. Since WeakTag is also an ObjectWrap derived class, handing it a WeakTag instance returns a non-null pointer that's really a WeakTag* misread as ObjectInfo*. The info_ == nullptr guard never catches this. WeakTag's destructor later calls info_->OnFree(), which reads/writes ObjectInfo shaped fields (target_, callback_) at offsets that don't exist in the actual (smaller) WeakTag object, an out-of-bounds access that corrupts memory and crashes V8 during GC, matching your trace.
Activity
urbanogilson commentedon Jul 28, 2026
Thanks for the detailed report and root-cause analysis.
ObjectInfo::Unwrap()is inherited fromNapi::ObjectWrap<T>::Unwrap, which is justnapi_unwrap+static_cast<T*>with no check that the object was actually constructed as anObjectInfo. SinceWeakTagis also anObjectWrapderived class, handing it aWeakTaginstance returns a non-null pointer that's really aWeakTag*misread asObjectInfo*. Theinfo_ == nullptrguard never catches this.WeakTag's destructor later callsinfo_->OnFree(), which reads/writesObjectInfoshaped fields (target_,callback_) at offsets that don't exist in the actual (smaller)WeakTagobject, an out-of-bounds access that corrupts memory and crashes V8 during GC, matching your trace.Fix WeakTag type confusion via unchecked ObjectInfo::Unwrap #1 (#2)