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
The use of CastedCData is to keep the refcount of \FFI\CData objects.
However, this solution is clearly ugly and causes confusing use-after-free.
Another solution is using \WeakMap. If we use partial\FFI\CData objects as keys to their root\FFI\CData object in a \WeakMap, we can guarantee that the root object will survive while at least one reference count of the partial objects remains.
There was a bug in php-src that prevented \WeakMap from being used with FFI extension objects, but a fix has already been released, so it's time to move to \WeakMap.
The text was updated successfully, but these errors were encountered:
The use of
CastedCData
is to keep the refcount of\FFI\CData
objects.However, this solution is clearly ugly and causes confusing use-after-free.
Another solution is using
\WeakMap
. If we use partial\FFI\CData
objects as keys to their root\FFI\CData
object in a\WeakMap
, we can guarantee that the root object will survive while at least one reference count of the partial objects remains.There was a bug in php-src that prevented
\WeakMap
from being used with FFI extension objects, but a fix has already been released, so it's time to move to\WeakMap
.The text was updated successfully, but these errors were encountered: