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
{{ message }}
Repository navigation
ffi enum type (when enum has no name) make memory leak #14286
<?php$ffi = FFI::cdef(" enum{ //enum TestEnum{ //if enum has a name there is no memory leak TEST_ONE=0, TEST_TWO=1, };");
echo$ffi->TEST_TWO; //echo 1 //the result is right but memory leak
i found the c ffi code when enum has no name make memory leak
changed the title [-]ffi enum type (when enm has no name) make memory leak[/-][+]ffi enum type (when enum has no name) make memory leak[/+]on May 21, 2024
Problem seems to be that for top-level anonymous type definition we never store the declaration anywhere else nor the type anywhere else. The declaration keeps owning the type and it goes out of scope. For anonymous fields this gets handled by the add_anonymous_field code that removes the type from the declaration. I think we should do something similar.
I tried this here, which seems to work, but it feels hacky: https://gist.github.com/nielsdos/62016be38fff00f97bfbee4a430cc009
Problem seems to be that for top-level anonymous type definition we never store the declaration anywhere else nor the type anywhere else. The declaration keeps owning the type and it goes out of scope. For anonymous fields this gets handled by the add_anonymous_field code that removes the type from the declaration. I think we should do something similar. I tried this here, which seems to work, but it feels hacky: https://gist.github.com/nielsdos/62016be38fff00f97bfbee4a430cc009
Activity
[-]ffi enum type make memory leak[/-][+]ffi enum type (when enm has no name) make memory leak[/+][-]ffi enum type (when enm has no name) make memory leak[/-][+]ffi enum type (when enum has no name) make memory leak[/+]ndossche commentedon May 21, 2024
Problem seems to be that for top-level anonymous type definition we never store the declaration anywhere else nor the type anywhere else. The declaration keeps owning the type and it goes out of scope. For anonymous fields this gets handled by the add_anonymous_field code that removes the type from the declaration. I think we should do something similar.
I tried this here, which seems to work, but it feels hacky: https://gist.github.com/nielsdos/62016be38fff00f97bfbee4a430cc009
avriltank commentedon May 22, 2024
thanks,patch this patch(https://gist.github.com/nielsdos/62016be38fff00f97bfbee4a430cc009) correct this Problem
phpGH-14286 (ffi enum type (when enum has no name) make memory leak)
Fix GH-14286 (ffi enum type (when enum has no name) make memory leak)
Merge branch 'PHP-8.2' into PHP-8.3
Merge branch 'PHP-8.3'