The fix https://github.com/BitOne/php-meminfo/pull/106 fixed an issue with a wrong frame name because the symbol table returned by the function zend_rebuild_symbol_table does not necessary return the symbol table of the current zend_execute_data.
The fix is correct but, since PHP 7.4, it is also the cause of a segfault.
Behavior in PHP 7.2/7.3
The symbol table of the current zend_execute_data can be the symbol table of:
the function meminfo_dump
a function with dynamic variables inside ($$dynamic_variable = test for example)
a function without dynamic variables inside
global context
etc
In any case, and even before the rebuild of the symbol table, the symbol table is initialized with an empty zend_array.
Therefore, it's possible to browse the symbol table of any frame, even meminfo_dump.
It does not make sense to browse this frame as it's not a "user" function though. With the fix in #106., this frame meminfo_dump is browsed.
Behavior in PHP 7.4
The symbol table is never initialized for:
the function meminfo_dump as it's not a user function
Also, the symbol table is not initialized in a function except if:
there is a dynamic variable
or a rebuild of the table with zend_rebuild_symbol_table is done
Therefore, when meminfo_dump frame is browsed, it tries to iterate over an uninitialized array.
See https://github.com/BitOne/php-meminfo/issues/108
Context
The fix https://github.com/BitOne/php-meminfo/pull/106 fixed an issue with a wrong frame name because the symbol table returned by the function
zend_rebuild_symbol_table
does not necessary return the symbol table of the currentzend_execute_data
.The fix is correct but, since PHP 7.4, it is also the cause of a segfault.
Behavior in PHP 7.2/7.3
The symbol table of the current
zend_execute_data
can be the symbol table of:meminfo_dump
$$dynamic_variable = test
for example)In any case, and even before the rebuild of the symbol table, the symbol table is initialized with an empty
zend_array
.Therefore, it's possible to browse the symbol table of any frame, even
meminfo_dump
. It does not make sense to browse this frame as it's not a "user" function though. With the fix in #106., this framememinfo_dump
is browsed.Behavior in PHP 7.4
The symbol table is never initialized for:
meminfo_dump
as it's not a user functionAlso, the symbol table is not initialized in a function except if:
zend_rebuild_symbol_table
is doneTherefore, when
meminfo_dump
frame is browsed, it tries to iterate over an uninitialized array.Fix
A possible solution would be to not browse frame that are not "user" function like it's done here: https://github.com/php/php-src/blob/php-7.4.13/Zend/zend_execute_API.c#L1476
But I prefered to only browse a frame corresponding to the rebuilt frame:
zend_rebuild_symbol_table
.