51Degrees / device-detection-php-onpremise

On-premise implementation of the 51Degrees Device Detection engines for the Pipeline API
Other
1 stars 3 forks source link

Offset used to retrieve an item from a collection was out of range. #4

Closed thias closed 2 years ago

thias commented 2 years ago

We are trying to use the onpremise module, but are getting some PHP Fatal Errors on some requests. Here is a custom json log of when it happens, with the UA as well as the message we get:

{"ua":"Mozilla\/5.0 (Linux; Android 11; LM-G820N) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/92.0.4515.159 Mobile Safari\/537.36","error":"Message:  Offset used to retrieve an item from a collection was out of range.\r\nSource:   \/builddir\/build\/BUILD\/device-detection-php-onpremise-6a8191db2de1c50e2acc959738ef8db36f6b3377\/NTS\/device-detection-cxx\/src\/common-cxx\/collection.c\r\nFunction: fiftyoneDegreesCollectionReadFileVariable\r\nLine:     1152\r\n"}
{"ua":"Mozilla\/5.0 (Windows NT 5.1; rv:27.0) Gecko\/20100101 Firefox\/27.0","error":"Message:  Offset used to retrieve an item from a collection was out of range.\r\nSource:   \/builddir\/build\/BUILD\/device-detection-php-onpremise-6a8191db2de1c50e2acc959738ef8db36f6b3377\/NTS\/device-detection-cxx\/src\/common-cxx\/collection.c\r\nFunction: fiftyoneDegreesCollectionReadFileVariable\r\nLine:     1152\r\n"}

We were using version 4.2.4, but even after updating to 4.3.3 the same messages appear. This is the module configuration that we are using:

extension=FiftyOneDegreesHashEngine.so
FiftyOneDegreesHashEngine.data_file=/usr/local/share/dbfiles/51Degrees/Enterprise-HashV41.hash
FiftyOneDegreesHashEngine.required_properties=HardwareVendor,HardwareName,DeviceType,PlatformName,PlatformVersion,BrowserName,BrowserVersion,IsWebApp,InVRMode
FiftyOneDegreesHashEngine.use_performance_graph=true

Any idea what could be causing this?

fatima51Degrees commented 2 years ago

Hi @thias

I can't manage to recreate this no matter how much I throw at it. Could you please provide following information to help us with diagnosing the problem.

Regards, Fatima

tungntpham commented 2 years ago

Hi @thias,

We believe this issue is a duplicate of this, so I will close this for now and will be monitoring this issue in the other thread instead.

Please feel free to reopen the issue if you think they are not the same.

Kind regards, Tung.

thias commented 2 years ago

Hi! Sorry for not taking the time to reply earlier.

Our environment is a custom PHP 7.3 build on RHEL7 (which is a bit old by today's standards). The binary packages we use can be found here: https://dl.marmotte.net/rpms/redhat/el7/x86_64/php-FiftyOneDegreesHashEngine-4.3.3-2.el7_9/ https://dl.marmotte.net/rpms/redhat/el7/x86_64/php-7.3.32-1.el7/

You'll find there also the build logs where a lot of useful information can be seen (gcc version, full compilation output, etc.)

And here is the spec file used for the above package: https://github.com/exogroup/rpms/tree/master/php-FiftyOneDegreesHashEngine

tungntpham commented 2 years ago

Hi @thias,

We have now managed to reproduced the issue when running with Apache server and currently working on a solution. Further details can be found in this thread. Please correct us if we're wrong but base on our understanding, you are running php with Nginx and php-fpm.

We will keep you updated once we have a release date for a fix.

Kind regards, Tung.

tungntpham commented 2 years ago

Hi @thias,

We have narrowed down the issue to how data is loaded in performance profiles other than MaxPerformance and HighPerformance. Please see this comment for further details. Thus we recommend that MaxPerformance profile is used in your environment to provide the best performance and to work around this issue for now.

To set the performance profile, please add the following line to your php.ini:

FiftyOneDegreesHashEngine.performance_profile=MaxPerformance

Or

FiftyOneDegreesHashEngine.performance_profile=HighPerformance

Please have a try and let us know if this works for you. We will keep you updated once we release the fix for other profiles.

Many thanks, Tung.

ben51degrees commented 2 years ago

Closing this issue with HighPerformance configuration as the solution. When forked by certain process managers, the extension does not support the use of other configurations. Documentation has been updated to give a full explanation, see https://github.com/51Degrees/device-detection-php-onpremise/tree/4.3.8#running-under-process-manager.