NumPower / numpower

PHP extension for efficient scientific computing and array manipulation with GPU support
https://numpower.org
Other
185 stars 4 forks source link

fix: destructor causing segmentation fault #59

Closed henrique-borba closed 2 months ago

henrique-borba commented 2 months ago

The destructor of an object is called even after the constructor has an exception, this was causing the call to NDArray_FREE from the destructor to cause a segmentation fault, since with the failure of __construct, the NDArray was not allocated in the object.

The destructor must check whether the array's UUID is properly defined before attempting to remove it from the buffer.

if (GC_REFCOUNT(object) <= 1 && Z_TYPE_P(obj_uuid) != IS_UNDEF) {