BitOne / php-meminfo

PHP extension to get insight about memory usage
MIT License
1.08k stars 78 forks source link

Make fails on PHP 7.3 in Linux #99

Closed rask closed 3 years ago

rask commented 4 years ago

When I follow the README instructions as such:

$ git clone ...
$ cd php-meminfo/extension/php7
$ phpize
$ make

On Ubuntu 18.04 I receive errors as such:

/bin/bash /home/ojrask/tmp/meminfo/php-meminfo/extension/php7/libtool --mode=compile cc  -I. -I/home/ojrask/tmp/meminfo/php-meminfo/extension/php7 -DPHP_ATOM_INC -I/home/ojrask/tmp/meminfo/php-meminfo/extension/php7/include -I/home/ojrask/tmp/meminfo/php-meminfo/extension/php7/main -I/home/ojrask/tmp/meminfo/php-meminfo/extension/php7 -I/usr/include/php/20190529 -I/usr/include/php/20190529/main -I/usr/include/php/20190529/TSRM -I/usr/include/php/20190529/Zend -I/usr/include/php/20190529/ext -I/usr/include/php/20190529/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /home/ojrask/tmp/meminfo/php-meminfo/extension/php7/meminfo.c -o meminfo.lo
mkdir .libs
 cc -I. -I/home/ojrask/tmp/meminfo/php-meminfo/extension/php7 -DPHP_ATOM_INC -I/home/ojrask/tmp/meminfo/php-meminfo/extension/php7/include -I/home/ojrask/tmp/meminfo/php-meminfo/extension/php7/main -I/home/ojrask/tmp/meminfo/php-meminfo/extension/php7 -I/usr/include/php/20190529 -I/usr/include/php/20190529/main -I/usr/include/php/20190529/TSRM -I/usr/include/php/20190529/Zend -I/usr/include/php/20190529/ext -I/usr/include/php/20190529/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /home/ojrask/tmp/meminfo/php-meminfo/extension/php7/meminfo.c  -fPIC -DPIC -o .libs/meminfo.o
/home/ojrask/tmp/meminfo/php-meminfo/extension/php7/meminfo.c: In function ‘zif_meminfo_dump’:
/home/ojrask/tmp/meminfo/php-meminfo/extension/php7/meminfo.c:61:66: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘size_t {aka long unsigned int}’ [-Wformat=]
     php_stream_printf(stream TSRMLS_CC, "    \"memory_usage\" : %d,\n", zend_memory_usage(0));
                                                                 ~^      ~~~~~~~~~~~~~~~~~~~~
                                                                 %ld
/home/ojrask/tmp/meminfo/php-meminfo/extension/php7/meminfo.c:62:71: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘size_t {aka long unsigned int}’ [-Wformat=]
     php_stream_printf(stream TSRMLS_CC, "    \"memory_usage_real\" : %d,\n", zend_memory_usage(1));
                                                                      ~^      ~~~~~~~~~~~~~~~~~~~~
                                                                      %ld
/home/ojrask/tmp/meminfo/php-meminfo/extension/php7/meminfo.c:63:71: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘size_t {aka long unsigned int}’ [-Wformat=]
     php_stream_printf(stream TSRMLS_CC, "    \"peak_memory_usage\" : %d,\n", zend_memory_peak_usage(0));
                                                                      ~^      ~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                      %ld
/home/ojrask/tmp/meminfo/php-meminfo/extension/php7/meminfo.c:64:76: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘size_t {aka long unsigned int}’ [-Wformat=]
     php_stream_printf(stream TSRMLS_CC, "    \"peak_memory_usage_real\" : %d\n", zend_memory_peak_usage(1));
                                                                           ~^     ~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                           %ld
/home/ojrask/tmp/meminfo/php-meminfo/extension/php7/meminfo.c: In function ‘meminfo_browse_class_static_members’:
/home/ojrask/tmp/meminfo/php-meminfo/extension/php7/meminfo.c:135:26: error: ‘zend_class_entry {aka struct _zend_class_entry}’ has no member named ‘static_members_table’; did you mean ‘static_members_table__ptr’?
         if (class_entry->static_members_table) {
                          ^~~~~~~~~~~~~~~~~~~~
                          static_members_table__ptr
/home/ojrask/tmp/meminfo/php-meminfo/extension/php7/meminfo.c:145:42: error: ‘zend_class_entry {aka struct _zend_class_entry}’ has no member named ‘static_members_table’; did you mean ‘static_members_table__ptr’?
                     prop = &class_entry->static_members_table[prop_info->offset];
                                          ^~~~~~~~~~~~~~~~~~~~
                                          static_members_table__ptr
/home/ojrask/tmp/meminfo/php-meminfo/extension/php7/meminfo.c: In function ‘meminfo_zval_dump’:
/home/ojrask/tmp/meminfo/php-meminfo/extension/php7/meminfo.c:358:22: warning: implicit declaration of function ‘Z_OBJDEBUG_P’; did you mean ‘Z_OBJCE_P’? [-Wimplicit-function-declaration]
         properties = Z_OBJDEBUG_P(zv, is_temp);
                      ^~~~~~~~~~~~
                      Z_OBJCE_P
/home/ojrask/tmp/meminfo/php-meminfo/extension/php7/meminfo.c:358:20: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
         properties = Z_OBJDEBUG_P(zv, is_temp);
                    ^
Makefile:191: recipe for target 'meminfo.lo' failed
make: *** [meminfo.lo] Error 1

And on a dockerized CentOS/RHEL environment the same procedure fails with errors similar to the following:

In file included from /opt/php-meminfo-master/extension/php7/meminfo.c:6:0:                                                                                                                                                      
/opt/php-meminfo-master/extension/php7/php_meminfo.h:21:65: error: unknown type name 'zend_string'                                                                                                                               
 void meminfo_zval_dump(php_stream * stream, char * frame_label, zend_string * symbol_name, zval * zv, HashTable *visited_items, int *first_element);                                                                                         
                                                                 ^                                                                                                                                                                            
In file included from /opt/php-meminfo-master/extension/php7/meminfo.c:6:0:                                                                                                                                                      
/opt/php-meminfo-master/extension/php7/php_meminfo.h:29:1: error: unknown type name 'zend_string'                                                                                                                                
 zend_string * meminfo_escape_for_json(const char *s);                                                                                                                                                                                        
 ^                                                                                                                                                                                                                                            
/opt/php-meminfo-master/extension/php7/meminfo.c: In function 'zif_meminfo_dump':                                                                                                                                                
/opt/php-meminfo-master/extension/php7/meminfo.c:57:5: warning: passing argument 1 of 'zend_fetch_resource' from incompatible pointer type [enabled by default]                                                                  
     php_stream_from_zval(stream, zval_stream);                                                                                                                                                                                               
     ^                                                                                                                                                                                                                                        
In file included from /usr/include/php/Zend/zend_API.h:27:0,                                                                                                                                                                                  
                 from /usr/include/php/main/php.h:38,                                                                                                                                                                                         
                 from /opt/php-meminfo-master/extension/php7/meminfo.c:5:                                                                                                                                                        
/usr/include/php/Zend/zend_list.h:83:16: note: expected 'struct zval **' but argument is of type 'struct zval *'                                                                                                                              
 ZEND_API void *zend_fetch_resource(zval **passed_id TSRMLS_DC, int default_id, const char *resource_type_name, int *found_resource_type, int num_resource_types, ...);                                                                       
                ^                                                                                                                                                                                                                             
/opt/php-meminfo-master/extension/php7/meminfo.c: In function 'meminfo_browse_exec_frames':                                                                                                                                      
/opt/php-meminfo-master/extension/php7/meminfo.c:83:5: error: unknown type name 'zend_array'                                                                                                                                     
     zend_array *p_symbol_table;                                                                                                                                                                                                              
     ^                        

(The error above is a snippet from the full error list, which is a lot longer.)

PHP version is 7.3.9, and PHP development tooling has been installed in both cases. PHP is installed from deb.sury.org on the Ubuntu machine, and from remirepo in the CentOS/RHEL image.

DonCallisto commented 4 years ago

Same here

SerzhYevtushenko commented 4 years ago

+1

lyrixx commented 4 years ago

I have almost the same error. So I'm pasting data here if it can help:

/bin/bash /tmp/php-meminfo/extension/php7/libtool --mode=compile cc  -I. -I/tmp/php-meminfo/extension/php7 -DPHP_ATOM_INC -I/tmp/php-meminfo/extension/php7/include -I/tmp/php-meminfo/extension/php7/main -I/tmp/php-meminfo/extension/php7 -I/usr/include/php/20190902 -I/usr/include/php/20190902/main -I/usr/include/php/20190902/TSRM -I/usr/include/php/20190902/Zend -I/usr/include/php/20190902/ext -I/usr/include/php/20190902/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /tmp/php-meminfo/extension/php7/meminfo.c -o meminfo.lo 
 cc -I. -I/tmp/php-meminfo/extension/php7 -DPHP_ATOM_INC -I/tmp/php-meminfo/extension/php7/include -I/tmp/php-meminfo/extension/php7/main -I/tmp/php-meminfo/extension/php7 -I/usr/include/php/20190902 -I/usr/include/php/20190902/main -I/usr/include/php/20190902/TSRM -I/usr/include/php/20190902/Zend -I/usr/include/php/20190902/ext -I/usr/include/php/20190902/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/php-meminfo/extension/php7/meminfo.c  -fPIC -DPIC -o .libs/meminfo.o
/tmp/php-meminfo/extension/php7/meminfo.c: In function 'meminfo_browse_class_static_members':
/tmp/php-meminfo/extension/php7/meminfo.c:135:26: error: 'zend_class_entry' {aka 'struct _zend_class_entry'} has no member named 'static_members_table'; did you mean 'static_members_table__ptr'?
         if (class_entry->static_members_table) {
                          ^~~~~~~~~~~~~~~~~~~~
                          static_members_table__ptr
/tmp/php-meminfo/extension/php7/meminfo.c:145:42: error: 'zend_class_entry' {aka 'struct _zend_class_entry'} has no member named 'static_members_table'; did you mean 'static_members_table__ptr'?
                     prop = &class_entry->static_members_table[prop_info->offset];
                                          ^~~~~~~~~~~~~~~~~~~~
                                          static_members_table__ptr
/tmp/php-meminfo/extension/php7/meminfo.c: In function 'meminfo_zval_dump':
/tmp/php-meminfo/extension/php7/meminfo.c:358:22: warning: implicit declaration of function 'Z_OBJDEBUG_P'; did you mean 'Z_OBJCE_P'? [-Wimplicit-function-declaration]
         properties = Z_OBJDEBUG_P(zv, is_temp);
                      ^~~~~~~~~~~~
                      Z_OBJCE_P
/tmp/php-meminfo/extension/php7/meminfo.c:358:20: warning: assignment to 'HashTable *' {aka 'struct _zend_array *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
         properties = Z_OBJDEBUG_P(zv, is_temp);
                    ^
make: *** [Makefile:191: meminfo.lo] Error 1
mfn commented 4 years ago

Same for 7.4 here on 18.04; is this package unmaintained?

mfn commented 4 years ago

Aha, there's https://github.com/BitOne/php-meminfo/pull/97 which fixes the compilation issues for me on 7.4

BitOne commented 3 years ago

Cannot reproduce with master on a PHP 7.3 using Sury packages. As the issue is quite old, must have been fixed by some other PR. So closing now.

If you encounter this issue with master, please re-open the issue.