51Degrees / Device-Detection

THE Fastest and most Accurate device detection for C / PHP / Perl / Python and Node.js - professionally maintained device data
https://51degrees.com/device-detection
Other
112 stars 46 forks source link

Issues building for PHP7 in Docker #26

Closed tylerreckart closed 6 years ago

tylerreckart commented 6 years ago

Hello,

I am currently having issues installing the PHP extension API inside of a Dockerized environment running php-fpm.

Here is the system I'm working in:

Ubuntu 16.04
PHP 7.0.3
g++ 5.4.0

Unlike the other PHP7 issues that I've researched while trying to debug this, I'm not hitting any errors when running make install. A few warnings are generated (see below), but the extension is still compiled and installed into the correct directory. We have been able to observe an error when PHP loads the extension (also below) that causes the container to terminate itself on startup because of a thrown instance of std::logic_error.

I've tried installing and compiling swig from the source as mentioned in previous PHP7 issues. I am able to verify that version 4.0.0 is installed into /usr/local/share/swig/[swig version]/, however even with version 4, I can still observe the warnings being generated during make install and the container still terminates.

Build Process

# Install and compile swig@4.0.0 (PHP7 support)
RUN cd / && \
    git clone https://github.com/swig/swig.git

RUN cd swig && \
    sh ./autogen.sh && \
    ./configure && \
    make && \
    make install

# Clean up
RUN cd / && \
    rm -rf swig

# Install & configure the 51Degrees extension
RUN cd / && \
    git clone https://github.com/51Degrees/Device-Detection.git

RUN cd Device-Detection/php/pattern && \
    phpize && \
    ./configure PHP7=1 && \
    make install

Warnings

In file included from /usr/include/php/20151012/main/php_ini.h:24:0,
                 from /usr/include/php/20151012/main/fopen_wrappers.h:26,
                 from /usr/include/php/20151012/main/php.h:391,
                 from /Device-Detection/php/pattern/src/pattern/51Degrees_PHP.cpp:751:
/Device-Detection/php/pattern/src/pattern/51Degrees_PHP.cpp: In function ‘int zm_startup_FiftyOneDegreesPatternV3(int, int)’:
/usr/include/php/20151012/Zend/zend_ini.h:141:73: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
 #define INI_STR(name) zend_ini_string_ex((name), sizeof(name)-1, 0, NULL)
                                                                         ^
/Device-Detection/php/pattern/src/pattern/51Degrees_PHP.cpp:4807:19: note: in expansion of macro ‘INI_STR’
  char *filePath = INI_STR("FiftyOneDegreesPatternV3.data_file");
                   ^
/usr/include/php/20151012/Zend/zend_ini.h:139:62: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
 #define INI_INT(name) zend_ini_long((name), sizeof(name)-1, 0)
                                                              ^
/Device-Detection/php/pattern/src/pattern/51Degrees_PHP.cpp:4808:17: note: in expansion of macro ‘INI_INT’
  int poolSize = INI_INT("FiftyOneDegreesPatternV3.pool_size");
                 ^
/usr/include/php/20151012/Zend/zend_ini.h:139:62: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
 #define INI_INT(name) zend_ini_long((name), sizeof(name)-1, 0)
                                                              ^
/Device-Detection/php/pattern/src/pattern/51Degrees_PHP.cpp:4809:18: note: in expansion of macro ‘INI_INT’
  int cacheSize = INI_INT("FiftyOneDegreesPatternV3.cache_size");
                  ^
/usr/include/php/20151012/Zend/zend_ini.h:141:73: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
 #define INI_STR(name) zend_ini_string_ex((name), sizeof(name)-1, 0, NULL)
                                                                         ^
/Device-Detection/php/pattern/src/pattern/51Degrees_PHP.cpp:4810:23: note: in expansion of macro ‘INI_STR’
  char *propertyList = INI_STR("FiftyOneDegreesPatternV3.property_list");

Docker Logs

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 99-change-ownership: executing...
[cont-init.d] 99-change-ownership: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
Allowing for debug
terminate called after throwing an instance of 'std::logic_error'
  what():  basic_string::_M_construct null not valid
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] syncing disks.
[s6-finish] sending all processes the TERM signal.
[s6-finish] sending all processes the KILL signal and exiting.

Thoughts on what I might be missing here?

JoshGrew51D commented 6 years ago

Hi There

The error below shown in the Docker log is usually due to settings within the php.ini either being invalid or missing.

basic_string::_M_construct null not valid

It is actually something I am working on for the next release, ensuring it it gives a more detailed response.

The default Pattern settings for the php.ini are: (leaving the property list empty returns them all)

extension=/path/to/module/FiftyOneDegreesPatternV3.so

 FiftyOneDegreesPatternV3.data_file=path/to/51Degrees/data/file.dat

 FiftyOneDegreesPatternV3.property_list=

 FiftyOneDegreesPatternV3.cache_size=10000

 FiftyOneDegreesPatternV3.pool_size=20

Take a look and let me know how you get on.

tylerreckart commented 6 years ago

@JoshGrew51D Thanks for the quick response. This was due to my misunderstanding of how to configure FiftyOneDegreesPatternV3.property_list=